home *** CD-ROM | disk | FTP | other *** search
/ LSD Docs / LSD Docs.iso / FILEZ / lsd39.dms / lsd39.adf / AmosAlmanac.doc.pp / AmosAlmanac.doc
Text File  |  1978-01-05  |  94KB  |  2,365 lines

  1.                    T H E   K E N T   T E A M   P R E S E N T
  2.  
  3.  
  4.                T H E   C O M P L E T E   A M O S   A L M A N A C
  5.  
  6.  
  7.                             I N T R O D U C T I O N   
  8.  
  9.  
  10. As this series was originally printed one article at a time and backed up by
  11. monthly CoverDisks, you may find at times that the text assumes that, for
  12. instance, you have a few sprites or a background picture on which to practice.
  13. These files would have been supplied with the original article. Simply
  14. substitute example files from the Amos program disks when this situation
  15. arises.
  16.  
  17.  
  18. Issue 42 ­ November 1991
  19. ` Putting together various previously discussed "modules" as the Pacman game
  20. begins to take shape
  21.  
  22. Entertainment software is big business now, and people have to be a little bit
  23. more creative to produce a good game, something which can be distinctly
  24. different to a good seller! Hopefully Amos will help you to spend a lot more of
  25. your time exercising these creative energies.
  26.  
  27. One important thing to remember about games software is that a lot of
  28. programmers cheat. We have covered different methods of `cheating` in previous
  29. issues. Some of the most amazing effects seen in games are, in fact, merely
  30. illusion ­ screen swapping, colour cycling and palette switching are just some
  31. of the ways to get amazing results without compromising the speed of your
  32. program.
  33.  
  34. Almost anybody can use these methods, but the real skill is in integrating them
  35. with the software so that they are invisible to the player, while at the same
  36. time making him or her think `wow, I wonder how they did that`?.
  37.  
  38. OK, the first step in any piece of software is to set up your screen, we`ve
  39. done all of this before ­ if you missed it then buy the back issues ­ so I
  40. won`t take you through all of the old details again:
  41.  
  42.         ' Set up
  43.         Screen Open 0,320,200,16,Lowres
  44.         Curs Off
  45.         Flash Off
  46.         Cls 0
  47.         Get Sprite Palette
  48.         Double Buffer
  49.         Autoback 0
  50.  
  51. Now we have the task of initialising all of the variables that we will use.
  52. Although Amos ­ and most other versions of Basic for that matter ­ does not
  53. require you to do this, it is a habit you should get into. After all, you won`t
  54. be using Amos forever, will you`
  55.  
  56. We will need to keep track of the X and Y position of our character, so we will
  57. use two variables call X_GOOD and Y_GOOD. As well as storing the position of
  58. our character the joystick status will have to be stored, so we will call that
  59. variable WAY:
  60.  
  61.         X_GOOD=150
  62.         Y_GOOD=100
  63.         WAY=0
  64.  
  65. Of course we will also need to move the bad guy around, so we will call its X
  66. and Y co-ordinates X_BAD and Y_BAD:
  67.  
  68.         X_BAD=0
  69.         Y_BAD=0
  70.  
  71. Finally we may want to introduce individual speeds for each of the characters
  72. in the game, so we will call these ­ guess what?  ­ GOOD_SPEED and BAD_SPEED.
  73. Notice that by using meaningful variable names we can tell a glance what a
  74. particular section of code is doing, but be careful of falling into the trap of
  75. ending up with variable names 40 characters long ­ they can be a real drag to
  76. type in!
  77.  
  78.         GOOD_SPEED=1
  79.         BAD_SPEED=1
  80.  
  81. Ohhhh, I almost forgot. This game is very simple and because of this it is
  82. going to be blindingly fast, so in order to slow it down we will only update
  83. everything occasionally. It sounds strange I know, but all will become clear
  84. very soon.
  85.         The variable we are going to use to control this is called T ­ or time!
  86. ­ and the variable used to hold the score is called SCORE:
  87.  
  88.         T=1
  89.         SCORE=0
  90.  
  91. Now we have to stick the player and the bad guy on to the screen. For this
  92. example program we are using BOBs, but you could use hardware SPRITEs:
  93.  
  94.         Bob 1,X_GOOD,Y GOOD,1
  95.         Bob 2,X_BAD, Y_BAD,2
  96.  
  97. Now for the main part of the game:
  98.  
  99.         Repeat
  100.  
  101. The first line here tells the program that we only want to execute everything
  102. inside the IF structure when the variable T has a value of two. At the moment
  103. it only has a value of one:
  104.  
  105.         If T=2
  106.  
  107. Our next task is to check the joystick to see if a movement has been made. We
  108. will use the JOY() function rather than the JUP/JDOWN functions, because it is
  109. more versatile. A fuller explanation as to why this is will be given in the
  110. next issue.
  111.         We store the current joystick value ­ which is a number between 0 and
  112. 16 ­ in the variable WAY. If WAY has a value greater than zero then we know
  113. that the joystick is being moved, and we can then test the direction and move
  114. our character:
  115.  
  116.         WAY=Joy(1)
  117.         If WAY>0
  118.  
  119. At this point we know that our man has moved so we can increase the score by
  120. one:
  121.  
  122.         Inc SCORE
  123.  
  124. Now comes the joystick testing bit. In a previous issue we saw how the JOY()
  125. function returns values depending on how it is currently positioned. Just to
  126. recap, these are the values for the four basic directions: UP=1, DOWN=2,
  127. LEFT=4, RIGHT=8.
  128.         Knowing this we can see if the player wants to move the character and
  129. so can increase/decrease the X_GOOD/Y_GOOD variables accordingly:
  130.  
  131.         If WAY=8
  132.                 Add X_GOOD,GOOD_SPEED,0 To 319
  133.         End If
  134.         If WAY=4
  135.                 Add X_GOOD,-GOOD_SPEED,0 To 319
  136.         End If
  137.         If WAY=1
  138.                 Add Y_GOOD,-GOOD_SPEED,0 To 199
  139.         End If
  140.         If WAY=2
  141.                 Add Y_GOOD,GOOD_SPEED,0 To 199
  142.         End If
  143.  
  144. Another trick when writing a game is not to update anything on the screen
  145. unless it has moved. For this reason we will only redraw our little character
  146. when the joystick has been moved:
  147.  
  148.         Bob 1,X_GOOD,Y_GOOD,1
  149.         End If
  150.  
  151. Here is a tricky question, with a very simple answer. How do you make a nasty
  152. home-in on your good guy? Well, imagine you were playing a game where you had
  153. to run after somebody. The brain would follow a simple set of rules, like: `If
  154. the person is to the left of me, I must move left,` and, `if the person is in
  155. front of me I must move forward.`
  156.  
  157.         These are the simple rules we can follow to make a `homer`. Of course
  158. most games have a slightly longer list of rules to control movement of bad guys
  159. and good guys, but at the end of the day they are still only a list of rules
  160. that the program must
  161. ollow.
  162.         I am sure you have played many games where after a while you realise
  163. that if you perform a certain action at a certain point, you can make the
  164. program do the same thing almost every time. This is because it is just
  165. following a set of simple ­ or com
  166. licated ­ rules:
  167.  
  168.         If X_GOOD<X_BAD
  169.                 Add X_BAD,-BAD_SPEED
  170.         Else
  171.                 Add X_BAD,BAD_SPEED
  172.         End If
  173.         If Y_GOOD<Y_BAD
  174.                 Add Y_BAD,-BAD_SPEED
  175.         Else
  176.                 Add Y_BAD,BAD_SPEED
  177.         End If
  178.  
  179. At this point we update the position of the bad guy and increase the value of
  180. the variable T. Remember that the ADD statement below has been written so that
  181. the number will wrap around from 1 to 2:
  182.  
  183.         Bob 2,X_BAD,Y_BAD,2
  184.         Add T,1,1 To 2
  185.  
  186. As we have seen earlier, to slow the game down we only update characters every
  187. second time we go through the loop. If the value of T is not 2 the program will
  188. just execute the next couple of lines and go back to the beginning:
  189.  
  190.         Else
  191.                 Add T,1,1 To 2
  192.         End If
  193.  
  194. Finally, we must set a stop condition on the REPEAT/UNTIL loop. In this case
  195. the program will stop if Bob number one collides with any other Bob. If a
  196. collision is detected your score is printed and the game ends!
  197.  
  198.         Until Bob Col(1)
  199.         Boom
  200.         Print `YOU ARE DEAD!!!! YOUR SCORE IS`;SCORE
  201.         Update
  202.         End
  203.  
  204. How long can you run around avoiding the nasty invader type beastie`. Why not
  205. experiment a little bit and see if you can add more bad guys and perhaps
  206. objects to collect. Before long you could be writing the follow up to
  207. Llamatron!
  208.  
  209. Finally, do not try to compile the game unless you slow it down, because it
  210. will end up impossibly fast! Remember that no piece of software is fixed, and
  211. if you do not like something about a game you write then change it!
  212.  
  213.  
  214. Issue 43 ­ December 1991
  215. ` Adding a maze to the rapidly developing Pacman game
  216.  
  217. Last month we saw how to get the good guy under joystick control and how to
  218. make the bad guy follow him. This month we will take a look at how to put a
  219. maze up on the screen.
  220.  
  221. OK, if you look at the screenshot on this page you should spot a nice picture
  222. of some maze blocks. In fact there are eight in total, four corners, two
  223. straight pieces, a small blob thing and a collectable pill (was Pacman a
  224. junkie?).
  225.  
  226. Why use blocks to build up a maze? The answer is simple ­ flexibility. By using
  227. blocks we can generate lots of different mazes using up only a fraction of the
  228. memory that a picture would take up.
  229.  
  230. If you take another look at the picture of the blocks you will notice they have
  231. numbers underneath. These will be used to build up our mazes. For example to
  232. build up a simple border we would use the following data:
  233.  
  234.         DATA "12222222222222222223"
  235.         DATA "4                  4"
  236.         DATA "4                  4"
  237.         DATA "4                  4"
  238.         DATA "4                  4"
  239.         DATA "4                  4"
  240.         DATA "4                  4"
  241.         DATA "4                  4"
  242.         DATA "4                  4"
  243.         DATA "4                  4"
  244.         DATA "4                  4"
  245.         DATA "52222222222222222226"
  246.  
  247. The number one represents the top left-hand corner and the number six
  248. represents the bottom-right.
  249.         To display this on-screen requires a little more work. The first thing
  250. to do is to dimension an array to hold the maze data. As each block is 16 x 16
  251. pixels our maze can only be made up of 20 blocks across and 12 blocks down.
  252. Because we are going to
  253. hold the block numbers in a string array we only need to dimension it to 11
  254. elements:
  255.  
  256.         Dim MAZE$(11)
  257.  
  258. The next step is to open up to a lo-res screen and clear it ready for drawing:
  259.  
  260.         Screen Open 0,320,200, 16, Lowres
  261.         Flash Off
  262.         Curs Off
  263.         Cls 0
  264.         Get Icon Palette
  265.  
  266. I have already prepared an icon bank for you on the CoverDisk which must be
  267. loaded into this listing before it will work:
  268.  
  269.         Load "MAZE_ICONS.ABK"
  270.  
  271. Things start to get a little more complex now. First we must read in a line of
  272. our maze data:
  273.  
  274.         For LOP=0 To 11
  275.         Read MAZE$(LOP)
  276.  
  277. Next we have to look at each part of that string to find out what maze block we
  278. would like to position on the screen at the next point:
  279.  
  280.         For LOP2=0 To 19
  281.         BLOCK-Val(Mid$(MAZE$(LOP), LOP2+1,1))
  282.  
  283. I always like to be careful when writing something like this. It is very easy
  284. to mistype a character so it is always worth putting a check in for strange
  285. values. Using this method we can automatically generate spaces in the maze if
  286. we want them while avoiding any error messages which Amos would throw up if we
  287. tried to display an icon that did not exist:
  288.  
  289.         If BLOCK>0 and BLOCK<9
  290.         Paste Icon LOP2*16,LOP*16,BLOCK
  291.         End If
  292.         Next LOP2
  293.         Next LOP
  294.  
  295. The maze!
  296.  
  297.         Data "12222222222222222223"
  298.         Data "48888888888888888884"
  299.         Data "48123812381223812384"
  300.         Data "484 485268522684 484"
  301.         Data "484 488888888888 484"
  302.         Data "48526812222223852684"
  303.         Data "4888884      4888884"
  304.         Data "48123852222226812384"
  305.         Data "484 488888888884 484"
  306.         Data "48526812222223852684"
  307.         Data "4888884      4888884"
  308.         Data "5222226      5222226"
  309.  
  310. Erm? What next? Well, it's a bit of a surprise actually. The method I have just
  311. showed you to draw the maze screens is OK, but we need a quick way to look at
  312. the maze shape to find out where the blocks are.
  313.  
  314. This way we can control the movement of any creatures we decide to put into the
  315. maze without resorting to slow and complex collision detection commands.
  316.  
  317. So we will now put all of the data needed to create a maze into an Amos memory
  318. bank which will be 240 bytes long (20 blocks wide x 12 blocks tall):
  319.  
  320.         Reserve As Work 10,240
  321.  
  322. We now have to set up that funky screen and load those icons again:
  323.  
  324.         Screen Open 0,320,200,16,Lowres
  325.         Flash Off
  326.         Curs Off
  327.         Cls 0
  328.         Get Icon Palette
  329.         Load "MAZE_ICONS.ABK"
  330.  
  331. This time we will read the data into memory bank 10 which we reserved earlier:
  332.  
  333.         For LOP=0 To 11
  334.         Read MAZE$
  335.         For LOP2=0 To 20
  336.  
  337.         BLOCK=Val(Mid$(MAZE$, LOP2+1,1))
  338.  
  339. Take note of the formula that is used to calculate the position of each block ­
  340. we will use a slightly adapted version of this for collision detection:
  341.  
  342.         POSITION=Start(10)+(LOP*20)+LOP2
  343.         Poke POSITION,BLOCK
  344.         Next LOP2
  345.         Next LOP
  346.  
  347. Once that is stored we can draw the screen by reading the data.
  348.  
  349. Simple formula time! Next month when we start to more our pacman around the
  350. maze, and will need a routine to make sure it does not career into any walls.
  351. We can find this out by constantly keeping a track of the position of our
  352. pacman and then using the following formulae to see if any walls blocks its
  353. path:
  354.  
  355.         UP=((Y-1)*20)=X
  356.         DOWN=((Y+1*20)+X
  357.         LEFT=(Y*20)+(X-1)
  358.         RIGHT=(Y*20)=(X+1)
  359.  
  360. If that seems a little bit confusing don't worry, everything will become clear
  361. as mud (sorry crystal)...
  362.  
  363.  
  364. Issue 44 ­ January 1992
  365. ` Making our pacmen move around the maze
  366.  
  367. In the days before hardware sprites and automatic collision detection,
  368. programmers still managed to produce games by looking at position of players,
  369. enemies and background objects.  They could then calculate whether or not they
  370. overlapped.
  371.  
  372. The first thing we must do to do this is set a working screen and load the
  373. Pacman sprites and maze icons in memory:
  374.  
  375.         Reserve As Work 10,240
  376.         Screen Open 0,320,200,16,Lowres
  377.         Flash Off
  378.         Curs Off
  379.         Cls 0
  380.         Hide On
  381.         Load `MAZE ICONS.ABK`
  382.         Load `PACMAN_SPRITES.ABK`
  383.         Get Icon Palette
  384.  
  385. OK, now we must define some simple variables.  Those of you who have just
  386. started to learn how to program will notice the GLOBEL statement. This lets our
  387. program know that the variables X and Y are used in all parts of the program
  388. (including procedures).
  389.  
  390.  
  391. If we did not execute this command, the procedures - which are really mini
  392. programs, independent of the main one ­ would assume that the variables X and Y
  393. were used only in themselves. It is probably easier to think of the GLOBEL as
  394. making the proced
  395. res share information:
  396.  
  397.         Globel X,Y
  398.         X=1
  399.         Y=1
  400.         MAKE_MAZE
  401.  
  402. OK, now is the interesting part. The formulas which are calculated into the
  403. variables UP, DOWN, LEFT and RIGHT check the position of our Pacman compared
  404. the maze data we have stored in
  405. bank 10.
  406.  
  407. If the joystick is pushed in a direction and there is a pill found there, the
  408. program will move the Pacman and erase the dot accordingly! If you remember how
  409. we built up the maze last time you will recall that the pills had a value of
  410. eight:
  411.  
  412.         Repeat
  413.                 UP=((Y-1)*20+X
  414.                 DOWN=((Y+1)*20+X
  415.                 LEFT=(Y*20)+(X-1)
  416.                 RIGHT=(Y*20)+(X+1)
  417.                 Bob 1,16*X,16*Y,2
  418.                 Wait 2
  419.                 WAY=Joy(1)
  420.                 If WAY<>0
  421.                         If WAY=1 and Peek(Start(10)+UP)=8
  422.                                 EACH_DOT
  423.                                 Dec Y
  424.                         End If
  425.                         If WAY=2 and Peek(Start(10)+DOWN)=8
  426.                                 EAT_DOT
  427.                                 Inc Y
  428.                         End If
  429.                         If WAY=4 and Peek(Start(10)+LEFT)=8
  430.                                 EAT_DOT
  431.                                 Dec X
  432.                         End If
  433.                         If WAY=8 and Peek(Start(10)+RIGHT)=8
  434.                                 EAT_DOT
  435.                                 Inc X
  436.                         End If
  437.                 End If
  438.    Until False
  439.    End
  440.  
  441. This procedure erases the pill when the Pacman moves:
  442.  
  443.         Procedure EAT_DOT
  444.                 Cls O,X*16+6,Y*16+6 To X*16+12,Y*16+12
  445.         End Proc
  446.  
  447. The following procedure is identical to the one we wrote last month to draw the
  448. maze:
  449.  
  450.         Procedure MAKE_MAZE
  451.                 For LOP=0 To 11
  452.                         Read MAZES
  453.                         '
  454.                         For LOP2=0 To 20
  455.                                 BLOCK=Val(Mid$(MAZES,LOP2+1,1))
  456.                                 POSITION=Start(10)+(LOP*20)+LOP2
  457.                                 '
  458.                                 Poke POSITION,BLOCK
  459.                                 '
  460.                         Next LOP2
  461.                         '
  462.                         For LOP=0 To 11
  463.                                 For LOP2=0 To 19
  464.                                         BLOCK=Peek(Start(10)+(LOP*20)+LOP2)
  465.                                         If BLOCK<>0
  466.                                         Paste Icon LOP2*16,LOP*16,BLOCK
  467.                                 End If
  468.                         Next LOP2
  469.                 Next LOP
  470.                 Wait Vbl
  471.                 Double Buffer
  472.                 '
  473.                 Data `12222222222222222223`
  474.                 Data `48888888888888888884`
  475.                 Data `48123812381223812384`
  476.                 Data `484 485268522684 484`
  477.                 Data `484 488888888884 484`
  478.                 Data `48526812222223852684`
  479.                 Data `4888884      4888884`
  480.                 Data `48123852222226812384`
  481.                 Data `484 488888888884 484`
  482.                 Data `48526812222223852684`
  483.                 Data `4888884      4888884`
  484.                 Data `5222226      5222226`
  485.         End Proc
  486.  
  487.  
  488. Issue 45 ­ February 1992
  489. ` Introducing ghosts to chase your pacman
  490.  
  491. As you will recall, we have now generated our maze and made a Pacman travel
  492. around it with our joysticks ­ now it`s time to introduce a nice ghostie to
  493. chase you. Some of the code we will be looking at will be familiar to you, but
  494. there are subtle differences between the program we looked at in the last issue
  495. and this one.
  496.  
  497. First we open our screens and reserve our bank to store the maze data. Then we
  498. load in the sprites and icons:
  499.  
  500.         Reserve As Work 10,240
  501.         Screen Open 0,320,200,16,Lowres
  502.         Flash Off
  503.         Curs off
  504.         Cls 0
  505.         Hide On
  506.         `
  507.         Load `PACMAN_SPRITES.ABK`
  508.         Load `MAZE_ICONS.ABK`
  509.         Load `MAZE_ICONS.ABK`
  510.         Get Icon Palette
  511.  
  512. Note that most of the code is now in separate procedures. This is to keep
  513. matters a little clearer when explaining things. As you write your own programs
  514. you will find it much more efficient to break them down into smaller, more
  515. manageable parts. This means that all of our variables must be declared as
  516. Global ­ if we do not do this, our procedures will not recognise them!
  517.  
  518. The next step is to generate the maze and execute the main loop:
  519.  
  520.         MAKE_MAZE
  521.         Repeat
  522.         Wait 2
  523.  
  524. Right, because we have changed things a little, the program now checks the
  525. joystick and moves our pacman by calling two procedures:
  526.  
  527.         CHECK_STICK
  528.         DO_PACMAN
  529.  
  530. Because our ghost is moving quite quickly we need to weigh the odds in our
  531. favour a little. To do this we will use a variable counter called PASS. Every
  532. time the loop is executed we increment this variable, and when it reaches three
  533. we move the ghost. So for every three moves we could make, the ghost will make
  534. one:
  535.  
  536.         If PASS=3
  537.         DO_GHOST
  538.         End If
  539.         Add
  540.         PASS,1,1 To 3
  541.  
  542. Finally, we will check to see if the ghost has hit the Pacman by comparing
  543. their co-ordinates. BX & BY are the ghost`s position X & Y are the Pacman`s
  544. position in the maze:
  545.  
  546.         Until(BX=X and BY=Y)
  547.         End
  548.  
  549. The next procedure is the one which makes the ghost so hard to beat. Remember
  550. how a couple of issues ago we looked at baddie intelligence` This program uses
  551. exactly the same method and follows these rules:
  552.  
  553. 1] IF PACMAN IS LEFT OF GHOST THEN MOVE GHOST LEFT ELSE MOVE GHOST RIGHT
  554.  
  555. 2] IF PACMAN IS ABOVE GHOST THEN MOVE GHOST UP ELSE MOVE GHOST DOWN
  556.  
  557. Of course, if a wall is in the way the pacman cannot move. You can easily
  558. overcome this by introducing more complex rules. Remember ­ baddie intelligence
  559. is always governed by a set of rules, simple or complex:
  560.  
  561.         Procedure DO_GHOST
  562.         If BX<>X
  563.          GHOST_RIGHT
  564.         Else
  565.          If BX>X
  566.           GHOST_LEFT
  567.          End If
  568.         End If
  569.         If BY>Y
  570.          GHOST_UP
  571.         Else
  572.          If BY<>Y
  573.           GHOST_DOWN
  574.          End If
  575.         End If
  576.         Bob 2,16*BX,16*BY,4
  577.         End Proc
  578.  
  579. The following procedures check to see if a wall is in the way before moving the
  580. ghost. Any value found in the maze band other than eight is classified as a
  581. wall. In more complex versions of the game you could check for power pellets,
  582. bonus fruits, and so on:
  583.  
  584.         Procedure GHOST_LEFT
  585.         B LEFT=(BY*20)+(BX-1)
  586.         If Peek(Start(10)+B_LEFT)=8
  587.          Dec BX
  588.         End If
  589.         End Proc
  590.         Procedure GHOST_RIGHT
  591.         B_RIGHT=(BY*20)+(BX+1)
  592.         If PEEK(Start(10)+B_RIGHT)=8
  593.          Inc BX
  594.         End If
  595.         End Proc
  596.         Procedure GHOST_UP
  597.         B_UP=((BY-1)*20)+BX
  598.         If Peek(Start(10)+B_UP)=8
  599.         Dec BY
  600.         End If
  601.         End Proc
  602.         Procedure GHOST_DOWN
  603.         B_DOWN=((BY+1)*20)+BX
  604.         If Peek(Start(10)+B_DOWN)=8
  605.         Inc BY
  606.         End If
  607.         End Proc
  608.  
  609. CHECK_STICK looks at the value stored in JOY(1). This contains a bitmap of the
  610. joystick position. If the value found is one it means that you are pushing the
  611. joystick up, two means down, four is left and eight is right. Just for
  612. reference, if the value of 16 is found then you have pressed Fire on the
  613. joystick!
  614.  
  615.         Procedure CHECK_STICK
  616.         WAY=Joy(1)
  617.         If WAY<>>0
  618.          If WAY=1 and Peek(Start(10)+UP)=8
  619.          EAT_DOT
  620.          Dec Y
  621.          End If
  622.          If WAY=2 and Peek(Start(10)+DOWN)=8
  623.           EAT_DOT
  624.           Inc Y
  625.          End If
  626.          If WAY=4 and Peek(Start(10)+LEFT)=8
  627.          EAT-DOT
  628.          DEC X
  629.          END IF
  630.          IF WAY=8 AND Peek(Start(10)+RIGHT)=8
  631.           EAT_DOT
  632.           Inc X
  633.          End If
  634.         End If
  635.         End Proc
  636.  
  637. This procedure does exactly the same as the routine we looked at last month.
  638. Basically it looks at the four directions surrounding the pacman to discover if
  639. a wall is in the way. It stores this information in the global variables UP,
  640. DOWN, LEFT, RIGHT:
  641.  
  642.         Procedure DO_PACMAN
  643.         UP=((Y-1)*20)=X
  644.         DOWN=((Y=1)*20)+X
  645.         LEFT=(Y*20)+(X-1)
  646.         RIGHT=(Y*20)+(X+1)
  647.         Bob 1,16*X,16*Y,2
  648.         End Proc
  649.  
  650. The next procedure does, guess what? Yes it erases the dot!
  651.  
  652.         Procedure EAT_DOT
  653.         Cls 0,X*16+6,Y*16+6 To X*16+12,Y*16+12
  654.         End Proc
  655.  
  656. Finally comes the procedure to generate the maze, which we looked at in depth a
  657. couple of issues ago.
  658.  
  659.         Procedure MAKE_MAZE
  660.         For LOP=0 To 11
  661.          Read MAZE$
  662.          `
  663.          For LOP2=0 To 20
  664.           BLOCK=Val(Mid$(MAZE$,LOP2+1,1))
  665.           POSITION=Start(10)+(LOP*20)+LOP2
  666.           `
  667.           Poke POSITION,BLOCK
  668.           `
  669.          Next LOP2
  670.         Next LOP
  671.         `
  672.         For LOP=0 To 11
  673.          For LOP2=0 To 19
  674.           BLOCK=PEEK(Start(10)+(LOP*20)+LOP2)
  675.           If BLOCK<>>0
  676.            Paste Icon LOP2*16,BLOCK
  677.           End If
  678.          Next LOP2
  679.         Next LOP
  680.         Wait Vbl
  681.         Double Buffer
  682.         `
  683.         Data "12222222222222222223"
  684.         Data ...
  685.  
  686.  
  687. Issue 46 ­ March 1992
  688. ` Taking a break from Pacman, and looking at Easy Amos, as well as some
  689. Funschool tips
  690.  
  691. Easy Amos is basically a version of Amos which has been designed for people who
  692. don`t know much about computer programming but want to learn, as well as people
  693. who know a little but find Amos just a little too daunting.
  694.  
  695. To describe it as a cut down version of Amos is a little unfair ­ there are a
  696. few commands and facilities which are missing (like menus) but it makes up for
  697. them with some really great new ones (like commands to load and play
  698. Soundtracker music without conversion!).
  699.  
  700. Easy Amos really is looking splendid. The manual ­ written by computer veteran
  701. Mel Croucher ­ is humorous and informative and incorporates lots of cartoons.
  702. There are loads of example programs on the accompanying disk which are
  703. documented and discussed in the manual, so there is only a little typing for
  704. those keyboard-shy beginners!
  705.  
  706. The whole appearance of the user interface has changed since its parent (Amos)
  707. was written. Everything is made up from the grey relief type boxes which we are
  708. so used to seeing in Workbench 2, and the editor now uses an eight colour
  709. screen to improved the rather bland look associated with four colour examples.
  710.  
  711. Everything about Easy Amos oozes friendliness. You can customise the actual
  712. language and the accompanying demos with your own name! It really is aimed at
  713. the absolute beginner.
  714.  
  715. One of the more advanced features of this new Amos is the Tutor. It is, in
  716. fact, a full source code debugger which will allow you to single step through
  717. your program in order to test it. You can set up break points and even set your
  718. own screens, Bobs, text and graphics up in a shrunk down window.
  719.  
  720. This is really amazing and has to be seen to be believed. I understand that
  721. Europress Software will be taking this feature and adding it to an improved
  722. `full` version of Amos currently dubbed `Amos II`. Roll on that day!!!
  723.  
  724. HERE`S a fabo tip for all of you programming Fun School 4 owners. On the Under
  725. 5s and 5 to 7s package a new experimental sound extension has been used! This
  726. is compatible with the StarTrekker program (a SoundTracker clone) and will
  727. allow you not only to play Soundtracker modules without using that dodgy
  728. converter but also supports the synthetic instrument/Sound FX option in
  729. StarTrekker!
  730.  
  731. The file is called `MUSIC.LIB` and is a direct replacement for the `MUSIC.LIB`
  732. file contained inside your `Amos_SYSTEM` directory, so all you have to do is
  733. copy it across. Unfortunately I do not have any details of the playing commands
  734. so you will have to route around the FS4 programs for more information about
  735. that.
  736.  
  737.  
  738. Issue 47 ­ April 1992
  739. ` An introduction to AMAL, the powerful Amos sub-language
  740.  
  741. Now it's time to really break free and attempt a task using something really
  742. meaty (or soya-beanie) if you are vegetarian) ­ AMAL.
  743.  
  744. We have covered AMAL previously, but not to write a whole game. Over the next
  745. couple of issues I will be showing you how to get the most out of this sub-
  746. language and more importantly how to use it in conjunction with the other (less
  747. powerful) parts of Amos.
  748.  
  749. You will notice that I have referred to AMAL as a sub-language. This is because
  750. it is a separate part of Amos and is quite capable of existing by itself. In
  751. many respects AMAL is similar to assembly language, especially in its use on
  752. mnemonics to represent the commands we use to create an AMAL program, and like
  753. assembly language, it must be well structured in order to keep tracks of any
  754. tasks we may ask of it.
  755.  
  756. To control AMAL we use a series of Channels ­ 16 in all. These can be assigned
  757. to control a single AMAL mini-program which will run alongside your main Amos
  758. program. Let's look at a way of using of AMAL. First we set up an AMAL channel
  759. using a command like this:
  760.  
  761.         Channel 1 To Screen Display 0
  762.  
  763. This would prepare your channel to accept an AMAL program. Now we will tell
  764. AMAL to feed the mouse co-ordinates into the external registers RA and RB,
  765. after which we will read and display them onscreen.
  766.  
  767. One thing to remember about AMAL is that you must type it exactly otherwise
  768. errors can occur quite easily. This is due to the fact that AMAL is case
  769. sensitive ­ that is, it can tell the difference between upper and lower case
  770. letters:
  771.  
  772.         mal 1,"Start: Let RA=XM ; Let RB=YM ; Jump Start ; "
  773.          Amal On1
  774.          Repeat
  775.             Print At(0,0);Amreg(0);" "
  776.            Print At(0,1);Amreg(1);" "
  777.          Until False
  778.  
  779. AMAL registers are like ordinary variables in Amos itself, and can be used to
  780. store numbers for calculations or later use. These are two types of AMAL
  781. register, internal and external. The internal registers are labelled R0 to R9
  782. and are mainly used for temporary storage of values within an AMAL program. The
  783. external registers are labelled RA to RZ and are (or at least should be) used
  784. for communicating with the outside world.
  785.  
  786. Reading these registers from your main Amos program is simple ­ we just use the
  787. AMREG() command (see your Amos manual for a fuller explanation of AMREG).
  788. Incidentally, you can store values in the AMAL registers from your main Amos
  789. program once again using the AMREG() command..
  790.  
  791. Being a fully featured sub-language means that AMAL programs can be quite long.
  792. For this reason AMAL allows you to structure commands within strings. I know it
  793. sounds a little weird but you do get used to it ­ trust me!
  794.  
  795. In the previous example we saw how to create a simple loop jumping from the end
  796. of the string back to the label "Start". Labels used for structuring AMAL
  797. programs are all single letters of the alphabet, in upper case. Because AMAL
  798. ignores all lower case letters you can pad out the label to create something a
  799. little more meaningful.
  800.  
  801. The next example is made up of may smaller strings "glued" together t create a
  802. single long string. You don't really want to know this but joining two or more
  803. strings together is known as concatenation:
  804.  
  805.         Channel 0 To Screen Display 0
  806.         A$="   Start:"
  807.         A$=A$+"      Pause ; "
  808.         A$=A$+"      Let Y=YM-100 ; "
  809.         A$=A$+"      If XM-160<64 Jump Start ; "
  810.         A$=A$+"      Let X=XM-160 ; "
  811.         A$=A$+"Jump Start ; "
  812.         Amal0,A$
  813.         Amal On 0
  814.  
  815. This program will work in direct more and will allow you to move the default
  816. screen around with the mouse. It's a little like the larger program which
  817. appeared last month.
  818.  
  819. Notice the way I have put each command on a separate line. I have also padded
  820. out the short labels and commands with lower case letters so that should I come
  821. back to the program in a couple of months I will be able to work out what it
  822. does quite easily.
  823.  
  824. AMAL also allows you to execute a simple form of FOR`NEXT loop, the main
  825. difference between the AMAL version and the actual Amos version of the loop is
  826. that you cannot perform STEPs (if you are unsure what a STEP is, check your
  827. Amos manual). The following example does the same job as the previous program,
  828. but only for a limited amount of times:
  829.  
  830.         Channel 0 To Screen Display 0
  831.         A$="   For R0=1 To 80"
  832.         A$=A$+"Start: "
  833.         A$=A$+"      Pause ; "
  834.         A$=A$+"      Let Y=YM-100 ; "
  835.         A$=A$+"      If XM-160<64 Jump Start ; "
  836.         A$=A$+"      Let X=XM-160 ; "
  837.         A$=A$+"Next R0 ; "
  838.         Amal0,A$
  839.         Amal On 0
  840.  
  841. If you look at the Amosteroids game which came with Amos you will see that most
  842. of the work is dome by AMAL ­ it controls the starship and asteroids. In fact
  843. the only things Amos has to do is play the samples and update the score during
  844. the game.
  845.  
  846. These AMAL programs need not be limited to controlling aliens in Xenon MXXIIX ­
  847. how about using them to make Bobs to follow your mouse` Or making constant
  848. calculations and feeding them into your main program using the AMAL registers?
  849.  
  850.  
  851. Issue 48 ­ May 1992
  852. ` Rewriting the Pacman game to take advantage of AMAL
  853.  
  854. If you can cast your mind back a couple of months, we were playing around with
  855. simple Bob movements using Amos. Our goal was to create a small Pacman game,
  856. which we did. Now we will look at a different method of creating such a game,
  857. using the Amos sub-language AMAL.
  858.  
  859. We took a look at the major AMAL functions in the last issue so I won`t be
  860. going into too much fine detail concerning the basic functions. Instead we will
  861. concentrate on the structure of an AMAL program.
  862.  
  863. The first thing to do is load in the Bobs for the game and set up our default
  864. screen stuff. If you are unsure how to get these Bobs loaded in ­ trust me when
  865. I say it`s not quite as straightforward as it sounds..
  866.  
  867.         Load `GAME_SPRITES.ABK`
  868.         Screen Open 0,320,200,16,Lowres
  869.         Curs Off
  870.         Flash Off
  871.         Cls 0
  872.         Get Sprite Palette
  873.         Double Buffer
  874.         Autoback 0
  875.  
  876. Now comes the time to define our AMAL string. As you can see, I have built the
  877. program up into the string A$. AMAL ignores spaces so I have taken advantage of
  878. this to produce a clear piece of code which is easy to look at and ­ hopefully
  879. ­ to understand.
  880.  
  881. The first line sets up a label `Start:` and after a brief pause stores the
  882. current joystick value in the register R0:
  883.  
  884.         A$=" Start: Pause ; Let R0=J1 ; "
  885.  
  886. By using comparisons we can then jump to routines depending on the current
  887. joystick action. As I have said before, the numbers returned by the joystick
  888. are 1=up, 2=down, 4=left, 5=right and in turn 9=up plus right (8+1=9), 6=down
  889. plus left (2+4=6) and so on.
  890.  
  891.         A$=A$="   If R0&8 Jump Right ; "
  892.         A$=A$="   If R0&4 Jump Left  ; "
  893.         A$=A$="   If R0&1 Jump Up  ; "
  894.         A$=A$="   If R0&2 Jump Down  ; "
  895.         A$=A$="   Jump Start     ;
  896.  
  897. The next four routines perform the actual movements of the Bob ­ for more
  898. details of how the Move command works see your Amos manual.
  899.  
  900.         A$=A$+"Right:           ; "
  901.         A$=A$+"    Move 10,0,2     ; "
  902.         A$=A$+"    Jump Start     ; "
  903.         A$=A$+"Left:           ; "
  904.         A$=A$+"    Move -10,0,2    ; "
  905.         A$=A$+"    Jump Start     ; "
  906.         A$=A$+"Up:            ; "
  907.         A$=A$+"    Move 0,-10,2    ; "
  908.         A$=A$+"    Jump Start     ; "
  909.         A$=A$+"Down:           ; "
  910.         A$=A$+"    Move 0,10,2     ; "
  911.         A$=A$+"    Jump Start     ; "
  912.         `
  913.         For LOP=1 To 15
  914.           Bob LOP,Rnd(150),Rnd(100),1
  915.           Channel LOP To Bob LOP
  916.           Amal LOP,A$
  917.         Next LOP
  918.         `
  919.         Wait Vbl
  920.  
  921. Amal On
  922.         `
  923.         Direct
  924.  
  925. OK, so you don`t want to structure your AMAL programs, you could shorten them
  926. by just using the UPPERCASE characters. Just look at the following AMAL string.
  927. If you value your sanity, don`t try to type it in!
  928.  
  929.         A$="S:P;LR0=J1;"
  930.         A$=A$+"IR0&8JR;"
  931.         A$=A$+"IR0&4JL;"
  932.         A$=A$+"IR0&1JU;"
  933.         A$=A$+"IR0&2JD; "
  934.         A$=A$+"JS;"
  935.         A$=A$+"R:;"
  936.         A$=A$+"M10,0,2;"
  937.         A$=A$+"JS;"
  938.         A$=A$+"L:;"
  939.         A$=A$+"M-10,0,2;"
  940.         A$=A$+"JS;"
  941.         A$=A$+"U:;"
  942.         A$=A$+"M0,-10,2;"
  943.         A$=A$+"JS;"
  944.         A$=A$+"D:;"
  945.         A$=A$+"M0,10,2;"
  946.         A$=A$+"JS;"
  947.  
  948. Having fun` I hope so! The final part of this exciting instalment gives us an
  949. AMAL-controlled player and baddie:
  950.  
  951.         Load "GAME_SPRITES.ABK"
  952.         Screen Open 0,320,200,16,Lowres
  953.         Curs Off
  954.         Flash Off
  955.         Cls 0
  956.         Get Sprite Palette
  957.         Double Buffer
  958.         Autoback 0
  959.         Bob 1,150,100,1
  960.         Bob 2,20,20,2
  961.  
  962. The string A$ is exactly the same as in the first program except that the
  963. horizontal and vertical positions of the player are fed into the external
  964. registers RA and RB. These are then read inside the baddie control program
  965. stored in B$ to make that the evil beastie tracks us down!
  966.  
  967.         A$="  Start: Pause ; Let R0=J1  ; "
  968.         A$=A$+"    Let RA=X ; Let RB=Y ; "
  969.         A$=A$+"    If R0&8 Jump Right ; "
  970.         A$=A$+"    If R0&4 Jump Left  ; "
  971.         A$=A$+"    If R0&1 Jump Up   ; "
  972.         A$=A$+"    If R0&2 Jump Down  : "
  973.         A$=A$+"    Jump Start     ; "
  974.         A$=A$+"Right:           ; "
  975.         A$=A$+"    Move 10,0,2     ; "
  976.         A$=A$+"    Jump Start     ; "
  977.         A$=A$+"Left:           ; "
  978.         A$=A$+"    Move -10,0,2     ; "
  979.         A$=A$+"    Jump Start      ; "
  980.         A$=A$+"Up:             ; "
  981.         A$=A$+"    Move 0,-10,2     ; "
  982.         A$=A$+"    Jump Start      ; "
  983.         A$=A$+"Down:            ; "
  984.         A$=A$+"    Move 0,10,2      ; "
  985.         A$=A$+"    Jump Start      ; "
  986.         `
  987.         B$=B$+"Start: Pause        ; "
  988.         B$=B$+"    If X>RA Jump Right ; "
  989.         B$=B$+"    If X<RA Jump Left  ; "
  990.         B$=B$+"    If Y>RB Jump Up   ; "
  991.         B$=B$+"    If X<RB Jump Down  ; "
  992.         B$=B$+"    Jump Start     ; "
  993.         B$=B$+"Right:           ; "
  994.         B$=B$+"    Move 10,0,2     ; "
  995.         B$=B$+"    Jump Start     ; "
  996.         B$=B$+"Left:           ; "
  997.         B$=B$+"    Move -10,0,2    ; "
  998.         B$=B$+"    Jump Start     ; "
  999.         B$=B$+"Up:            ; "
  1000.         B$=B$+"    Move 0,-10,2    ; "
  1001.         B$=B$+"    Jump Start     ; "
  1002.         B$=B$+"Down:           ; "
  1003.         B$=B$+"    Move 0,10,2     ; "
  1004.         B$=B$+"    Jump Start     ; "
  1005.         `
  1006.         Channel 1 To Bob 1
  1007.         Amal 1,A$
  1008.         Channel 2 To Bob 2
  1009.         Amal 2,B$
  1010.         Amal On 1
  1011.         Wait Vbl
  1012.         Amal On 2
  1013.         `
  1014.         Repeat
  1015.           Inc SCORE
  1016.         Until Bob Col(1)
  1017.         Boom
  1018.         Print "YOU ARE DEAD!!!! YOUR SCORE IS";SCORE
  1019.         Update
  1020.  
  1021. That brings us to the end of a very practical column!
  1022.  
  1023.  
  1024. Issue 49 ­ June 1992
  1025. ` Creating wonderful worlds and "alternate realities" with your Amiga's 4,096
  1026. colours
  1027.  
  1028. Your Amiga is blessed with a wonderful collection of 4,096 different colours.
  1029. With these colours we can create new worlds and alternate realities with art
  1030. packages like Deluxe Paint. With Amos we can go a step further and use the
  1031. power of colour to produce animation.
  1032.  
  1033. Before we go into too much detail, it will help for you to know a little bit
  1034. about the way colours are handled by the Amiga. Under ordinary circumstances
  1035. you can display 32 individual colours on-screen. These are stored in colour
  1036. registers. You can think of a colour register as being an empty paint pot,
  1037. which we can fill up with any colour.
  1038.  
  1039. At its simplest form you can see colour cycling at fairgrounds and fancy
  1040. Christmas displays. This happens when  a string of unlit bulbs are switched on
  1041. in sequence one at a time. This gives the illusion that a bulb is moving along.
  1042. We can demonstrate this with a simple program.
  1043.  
  1044. The first step is to open up our screen, so go into the Amos editor and type:
  1045.  
  1046.         Screen Open 0,320,200,16,Lowres
  1047.         Flash Off
  1048.         Cl 0
  1049.         Curs Off
  1050.  
  1051. Now we must set up our palette. Remember that each of the numbers in the
  1052. following line represent the "paint" that we are pouring into the paint pot
  1053. (colour register).
  1054.  
  1055. The colour which we have poured into colour register number one ­ remember that
  1056. the 32 different colour registers are labelled from 0 to 31 ­ is white ($FFF)
  1057. and represents our bulb which is switched on:
  1058.  
  1059.         Palette
  1060.         $0,$FFF,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,
  1061.  
  1062. Now we must draw our lightbulbs. Each one will use a different colour, selected
  1063. with the PEN command:
  1064.  
  1065.         Paper 0
  1066.         For LOP=1 To 15
  1067.          Pen LOP
  1068.          Wait Vbl
  1069.          Print "0";
  1070.         Next LOP
  1071.  
  1072. The final stage is to start the colour cycling up. We will do this using the
  1073. Shift command, which uses four parameters. The first is the speed at which the
  1074. colours will cycle, the second and third specify the start and end colour
  1075. registers which will be cycled and the final parameter is for special effects -
  1076. which we will not be using!
  1077.  
  1078. Just how does it work? Well, the Shift command will move the colour stored in
  1079. register number 1 into register number 2, the colour in register 2 into
  1080. register 3, 3 into 4, 4 into 5 etc. It's a bit like pouring the paint from one
  1081. pot into another!
  1082.  
  1083.         Shift Up 2,1,15,1
  1084.         Direct
  1085.  
  1086. That's it. Simple, huh?
  1087.  
  1088. Another interesting use of colour cycling is to produce weird backgrounds for
  1089. games and demos ­ or hypnotising friends and relatives!
  1090.  
  1091. In the next example we will draw a small block 16 x 16 pixels in size, grab it
  1092.  
  1093. as a Bob and finally paste it all over the screen. Once again, our screen must
  1094. be opened up, and a palette selected. In this case I have used shades of blue:
  1095.  
  1096.         Screen Open 0,320,200,16,Lowres
  1097.         Flash Off
  1098.         Cls 0
  1099.         Palette $0,$5,$6,$8,$9,$B,$C,$E,$F
  1100.  
  1101. Now we will read in the data ­ sorry, but there is quite a lot of it! ­ and
  1102. draw it onto the screen:
  1103.  
  1104.         For Y=0 To 15
  1105.          For X=0 To 15
  1106.           Read SPOT
  1107.            Ink SPOT
  1108.           Plot X,Y
  1109.          Next X
  1110.         Next Y
  1111.  
  1112. By using the Get Bob command we can grab this small block and stick it all over
  1113. the screen, 20 blocks across and 12 blocks down:
  1114.  
  1115.         Get Bob 1,0,0 To 16,16
  1116.         For Y=0 To 11
  1117.          For X=0 To 19
  1118.           Paste Bob X*16,Y*16,1
  1119.          Next X
  1120.         Next Y
  1121.  
  1122. We must now start that funky colour cycling! This time we will be cycling
  1123. colours 1 to eight:
  1124.  
  1125.  Shift Up 4,1,8,1
  1126.  End
  1127.  Data $1,$1,$1,$1,$1,$1,$1,$1,$1,$2,$3,$4,$5,$6,$7,$8
  1128.  Data $1,$2,$2,$2,$2,$2,$2,$2,$1,$2,$3,$4,$5,$6,$7,$7
  1129.  Data $1,$2,$3,$3,$3,$3,$3,$1,$2,$3,$4,$5,$6,$6,$6,$6
  1130.  Data $1,$2,$3,$4,$4,$4,$4,$4,$1,$2,$3,$4,$5,$5,$5,$5
  1131.  Data $1,$2,$3,$4,$5,$5,$5,$5,$1,$2,$3,$4,$4,$4,$4,$4
  1132.  Data $1,$2,$3,$4,$5,$6,$6,$6,$1,$2,$3,$3,$3,$3,$3,$3
  1133.  Data $1,$2,$3,$4,$5,$6,$7,$7,$1,$2,$2,$2,$2,$2,$2,$2
  1134.  Data $1,$2,$3,$4,$5,$6,$7,$8,$1,$1,$1,$1,$1,$1,$1,$1
  1135.  Data $1,$1,$1,$1,$1,$1,$1,$1,$8,$7,$6,$5,$4,$3,$2,$1
  1136.  Data $2,$2,$2,$2,$2,$2,$2,$1,$7,$7,$6,$5,$4,$3,$2,$1
  1137.  Data $3,$3,$3,$3,$3,$3,$2,$1,$6,$6,$6,$5,$4,$3,$2,$1
  1138.  Data $4,$4,$4,$4,$4,$3,$2,$1,$5,$5,$5,$5,$4,$3,$2,$1
  1139.  Data $5,$5,$5,$5,$4,$3,$2,$1,$4,$4,$4,$4,$4,$3,$2,$1
  1140.  Data $6,$6,$6,$5,$4,$3,$2,$1,$3,$3,$3,$3,$3,$3,$2,$1
  1141.  Data $7,$7,$6,$5,$4,$3,$2,$1,$2,$2,$2,$2,$2,$2,$2,$1
  1142.  Data $8,$7,$6,$5,$4,$3,$2,$1,$1,$1,$1,$1,$1,$1,$1,$1
  1143.  
  1144. Have fun with colour cycling and send in any examples that you come up with.
  1145.  
  1146. We have seen how to create a simple Pacman-type game in Amos, but what's next?
  1147. How about education! An absolute wealth of educational software has appeared in
  1148. shops and in public domain catalogues since the release of Amos.
  1149.  
  1150. Many people who have good ideas but have been unable to implement them into
  1151. traditional languages ­ like Amiga Basic ­ have found that Amos allows them to
  1152. breathe life into their ideas.
  1153.  
  1154.  
  1155. Issue 50 ­ July 1992
  1156. ` Producing smooth and fast scrolls for use in games
  1157.  
  1158. Many people bought Amos in the belief that it would let them make fantastic
  1159. software with ease, save the universe as we know it and make the perfect cup of
  1160. coffee.
  1161.  
  1162. Unfortunately life is never that simple and to get any satisfaction from using
  1163. this language you will have to get to know your Amiga and its capabilities a
  1164. little better. It also helps to have good Colombian beans.
  1165.  
  1166. There are two main methods of producing scrolling screens. The first is to take
  1167. a series of interconnecting picture blocks, put one on the screen, move it a
  1168. bit and then place the next section.
  1169.  
  1170.  
  1171. This is known as a software scroll because it is up to us ­ the programmers ­
  1172. to do all of the hard work. Xenon II uses this type of scrolling. One of the
  1173. advantages of software scrolling is that it requires very little memory,
  1174. because you really only have to have a standard sized screen open which is 320
  1175. x 200 pixels in size.
  1176.  
  1177. A hardware scroll is something which is handled mainly by the Amiga's custom
  1178. chips, which are known as hardware. It is produced by defining a big picture,
  1179. looking at one section of the picture and then panning across the rest, just
  1180. like a television looking at a wall-mounted mural. Kick Off uses this type of
  1181. scrolling.
  1182.  
  1183. Although fast, hardware scrolling eats up lots of memory. Fortunately, the ease
  1184. with which we can manipulate a hardware scroll more than makes up for the
  1185. memory consumption. Before we do this I think we should look at how versatile
  1186. the Amiga's screen system really is.
  1187.  
  1188. Amiga screens are something special. You need to imagine them not as literal
  1189. pictures but as a window looking into your machine's memory. By moving our
  1190. viewpoint around we can examine almost any part of the chip memory contained
  1191. inside the Amiga. Incidentally, this is how many graphics "grabbers" work.
  1192.  
  1193. Amos allows us to manipulate these "windows on the world" using Screen Display
  1194. and Screen Offset commands. Screen Offset controls our view of the computer's
  1195. memory through our window, while Screen Display controls the size of this
  1196. window and its position on the monitor.
  1197.  
  1198. OK, now we all know how to open a screen inside Amos, don't we? It's pretty
  1199. simple ­ load Amos and make sure you are inside the editor (not Direct Mode).
  1200. Type this line in:
  1201.  
  1202.         Screen Open 0,320,200,16,Lowres
  1203.  
  1204. This tells Amos to create screen number 0 with a horizontal resolution of 320
  1205. pixels, a vertical resolution of 200 pixels and 16 colours in lo-res mode,
  1206. which means the pixels are pretty square and chunky. We now have a screen we
  1207. can experiment with.
  1208.  
  1209. The next step is to define two variables XSIZE and YSIZE ­ these will tell Amos
  1210. how big our window will be:
  1211.  
  1212.         XSIZE=320
  1213.         YSIZE=200
  1214.  
  1215. OK, now we must start a loop which will allow us to change the characteristics
  1216. of this window with the mouse buttons. Every time we go around the loop, the
  1217. mouse co-ordinates are put into the variables X and Y.
  1218.  
  1219. These are then used to position the window on your monitor. It sounds
  1220. confusing, but if you imagine the window as a piece of paper being moved around
  1221. the desk ­ which is your monitor! ­ it may sound a little clearer:
  1222.  
  1223.         Repeat
  1224.         X=X Mouse-100
  1225.         Y=Y Mouse-160
  1226.  
  1227. Now we must check the state of the mouse keys. If the left button is pressed
  1228. the variable XSIZE is decremented. If the right button is pressed the variable
  1229. YSIZE is decremented. The command ADD allows a little more control over
  1230. variables than the standard INC or DEC commands. By using ADD we can make the
  1231. number contained in XSIZE wrap from 0 to 320 with very little work:
  1232.  
  1233.         If Mouse Key=1
  1234.                 Add XSIZE,-1,1 To 320
  1235.         End If
  1236.         If Mouse Key=2
  1237.                 Add YSIZE,-1,1 To 200
  1238.         End If
  1239.  
  1240. OK, now for the magic command. As you can see the first parameter is the screen
  1241. number., followed by the X and Y positions plus XSIZE and YSIZE:
  1242.  
  1243.         Screen Display 0,X,Y,XSIZE,YSIZE
  1244.  
  1245. The final part of our program waits for you to press both mouse keys before it
  1246. stops:
  1247.  
  1248.         Until Mouse Key=3
  1249.         End
  1250.  
  1251. I hope this has not been too complicated to follow so far. The concepts are
  1252. simple, but I must admit that the whole subject can become overpowering!
  1253.  
  1254. I have now introduced you to the basics of using Screen Display, but what about
  1255. Screen Offset? It is this command which actually creates the scrolling. If we
  1256. designed a standard screen size and used Screen Offset to look above ­ or below
  1257. ­ it, we would see what is contained in those portions of memory.
  1258.  
  1259. To start off with, let's open up our screen by typing the following lines into
  1260. the Amos editor (remember to Save your last program if you want to keep it):
  1261.  
  1262.         Screen Open 0,320,200,4,Lowres
  1263.         Flash Off
  1264.         Hide On
  1265.         Curs Off
  1266.         Palette $0,$90
  1267.         Cls 1
  1268.  
  1269. You will notice that I have reduced the amount of colours from the standard 16
  1270. down to four. I have also increased the size of the screen to 600 pixels high,
  1271. which is three times the height of a normal screen.
  1272.  
  1273. The next Screen Display command features four commas in succession. This is not
  1274. a typing error! It tells Amos to use its own defaults instead of the missing
  1275. parameters. The last part of the line tells Amos that we only want to display
  1276. 200 lines of the 600 line screen:
  1277.  
  1278.         Screen Display 0,,,,200
  1279.  
  1280. I am not a great lover of football ­ or football simulation computer games ­
  1281. but they can be useful to demonstrate the principles we are dealing with here.
  1282. So in the best tradition of Blue Peter, here is a pitch I drew earlier:
  1283.  
  1284.         Draw 0,299 To 320,299
  1285.         Box 0,0 To 319,599
  1286.         Circle 160,299,105
  1287.  
  1288. Even though we cannot see the whole screen, Amos will draw it for us. Neat,
  1289. huh? The penultimate step in this program is to let Amos know which part of the
  1290. 600-line screen we wish to display inside our small 200-line window. Once
  1291. again, the Screen Offset command contains a couple of commas, which tells Amos
  1292. to use the default value for the X position of our view:
  1293.  
  1294.         YPOS=0
  1295.         Screen Offset 0,,YPOS
  1296.  
  1297. Now for the exciting bit! By pressing the left mouse button the screen will
  1298. scroll smoothly upwards by telling Amos ­ through the Screen Offset command ­
  1299. to look at a different part of the picture held in memory through our small
  1300. screen or "window". If we press the right button the screen will scroll
  1301. downward:
  1302.  
  1303.         Repeat
  1304.                 If Mouse Key=1 and YPOS.0
  1305.                         Add YPOS,-5
  1306.                         Screen Offset 0,,YPOS
  1307.                 End If
  1308.                 If Mouse Key=2 and YPOS,400
  1309.                         Add YPOS,5
  1310.                         Screen Offset 0,,YPOS
  1311.                 End If
  1312.  
  1313. We must put a WAIT VBL command here to tell Amos to slow down. Try removing it
  1314. to see how fast the program runs!
  1315.  
  1316.         Wait Vbl
  1317.         Until Mousekey=3
  1318.  
  1319. Why not experiment and see what you come up with?
  1320.  
  1321.  
  1322. Issue 51 ­ August 1992
  1323. ` Generating Amiga windows and menus
  1324.  
  1325. If you are coding something other than a game, you`ll have to get used to
  1326. generating Amiga windows and menus. This is much easier in Amos than it is in,
  1327. say, AmigaBasic, where you have to specify everything so precisely you might as
  1328. well draw it on the screen with a Biro.
  1329.  
  1330. Getting a screen together is easy enough with the Screen Open command, but what
  1331. do you have to do to make the screen and its windows act like a normal Amiga
  1332. program` I`ve been doing a lot of this sort of thing lately, so try this
  1333. listing for size:
  1334.  
  1335.         Screen Open 0,640,256,16,Hires
  1336.  
  1337. Nice and simple to start with. Just a med-res screen to give you that utility
  1338. look. Now we define our menus:
  1339.  
  1340.         MenuS(1)=` Project     `
  1341.         MenuS(1,1)=` Load     `
  1342.         MenuS(1,2)=` Load As...     `
  1343.         MenuS(1,3)=` Save     `
  1344.         MenuS(1,4)=` Save As...     `
  1345.  
  1346. That`s menu 1 sorted and as you can see it`s a very simple procedure to name
  1347. the menus, with 1 being the menu title, and 1,1 being a submenu. We do the same
  1348. for the next menu, but with a little twist:
  1349.  
  1350.         MenuS(2)=` CyberSpace     `
  1351.         MenuS(2,1)=` Engage!     `
  1352.         MenuS(2,1,1)=` Are you sure`     `
  1353.         MenuS(2,1,1,1)=` Yes - GO!!     `
  1354.         MenuS(2,1,1,2)=` No - Abort     `
  1355.         MenuS(2,2)=` Morph     `
  1356.         MenuS(2,3)=` ID scan     `
  1357.         MenuS(2,4)=` Alter ID     `
  1358.  
  1359. You can go on adding submenus like 2,1,1,1,1,1 to infinity, but bear in mind
  1360. that anything other than one or two submenus really gets on the operators?
  1361. nerves after a very short while. Finally we turn the menus on:
  1362.  
  1363.         Menu On
  1364.  
  1365. and at this point the menus are active. You can of course turn them off later
  1366. if you don`t want anyone using the menus at a certain point in the program.
  1367. Finally, for the benefit of our listing, a few cosmetic and diagnostic details:
  1368.  
  1369.         Curs Off : Cls O
  1370.         Do
  1371.         Print `Menu= `;Choice(1);`
  1372.         Selection= `;Choice(2)
  1373.         Loop
  1374.  
  1375. You can now run the program. Notice how the menu and selection numbers change
  1376. when you select a different menu item. This is how you know what the user has
  1377. selected, and it`s simply that.
  1378.  
  1379. Find out what choice 1 and 2 are and you know what menu item was under the
  1380. pointer when the user let go of the RMB. But to really get to grips with the
  1381. menus, especially if you have a number of them, you have to use the Amos auto
  1382. menuing system within Menu On. This takes a little bit of practice, but it`s
  1383. really quite simple. The revised program starts the same, pretty much:
  1384.  
  1385.         Screen Open 0,640,256,16,Hires
  1386.         Cls 0 : Curs Off
  1387.         MenuS(1)=`Project     `
  1388.         MenuS(1,1)=`Load     `
  1389.         MenuS(1,2)=`Load As...     `
  1390.         MenuS(1,3)=`Save     `
  1391.         MenuS(1,4)=`Save As...     `
  1392.         MenuS(2)=`CyberSpace     `
  1393.         MenuS(2,1)=`Engage!     `
  1394.         MenuS(2,1,1)=`Are you sure`     `
  1395.         MenuS(2,1,1,1)=`Yes - GO!!     `
  1396.         MenuS(2,1,1,2)=`No - Abort     `
  1397.         MenuS(2,2)=`Morph     `
  1398.         MenuS(2,3)=`ID scan     `
  1399.         MenuS(2,4)=`Alter ID     `
  1400.  
  1401. But at this point it diverts into new territory:
  1402.  
  1403.         On Menu Proc PROJECT,CYBER
  1404.         On Menu On
  1405.         Menu On
  1406.         Wait Key
  1407.  
  1408. This turns on the auto menuing system and waits for you to either make a
  1409. selection from the menus or press a key on the keyboard. The PROCs you
  1410. mentioned in the ON MENU ON statement are then defined somewhere else in the
  1411. program, like right now for example:
  1412.  
  1413.         LISTINGS MACRO2 Procedure PROJECT
  1414.         Cls
  1415.         Y=Choice(2)
  1416.         Locate 0,22 : Print `Menu: Project`
  1417.         Locate 0,23
  1418.         If Y=1 Then Print `Load what``
  1419.         If Y=2 Then Print `Load as what``
  1420.         If Y=3 Then Print `Save what``
  1421.         If Y=4 Then Print `Save as what``
  1422.         OM
  1423.         End Proc
  1424.         Procedure CYBER
  1425.         Cls
  1426.         Y=Choice(2)
  1427.         Locate 0,22 : Print `Menu: Cyberspace`
  1428.         Locate 0,23
  1429.         If Y=1 Then Print `Yes Or No` Which is it``
  1430.         If Y=2 Then Print `Morph yourself`
  1431.         If Y=3 Then Print `Okay you`re scanned`
  1432.         If Y=4 Then Print `You can`t change ID`
  1433.         OM
  1434.         End Proc
  1435.         End
  1436.         Procedure OM
  1437.         On Menu On
  1438.         End Proc
  1439.  
  1440. And there you have it. The responses are put into PROCs and this makes the
  1441. whole thing a lot simpler. You only have to scan for one variable CHOICE(2) as
  1442. the first one, the menu itself is chosen for you automatically, and you`re sent
  1443. right to the PROC that deals with that menu.
  1444.  
  1445. Once you`ve got subroutines accepting input from menus, you`ve got yourself the
  1446. basis for a mighty fine menu driven utility program.
  1447.  
  1448.  
  1449. Issue 52 ­ September 1992
  1450. ` Altering text font, colour and sizes
  1451.  
  1452. Text in computer programs is something you take for granted. I know I do, and
  1453. it`s hard to think beyond the kind of things that have been possible in
  1454. AmigaBasic, which is what most people`s programming experience consists of pre-
  1455. Amos.
  1456.  
  1457. But Amos opens up new vistas of programming, and simply too. This month we`ll
  1458. be looking at how you can spice up your text, whether it be a game logo, high
  1459. score table, or just the title screen of your new business program.
  1460.  
  1461. Text in a computer program tells you two things. The words on the screen tell
  1462. you what to do, and the style with which they do it tells you a lot about the
  1463. programmer`s attention to detail.
  1464.  
  1465. Normal text tricks include clever formatting and changes of colour. But more
  1466. impressive are changes of font and size. It`s like the difference between
  1467. typing on a typewriter and making up your text in a DTP program.
  1468.  
  1469. Firstly if you don`t want to faff about with fonts, make your titles a
  1470. different colour with Pen and centre them with Centre. But there are two kinds
  1471. of text in Amos - normal text and what they call `graphic text`. Normal text is
  1472. printed to the screen with a Print statement, but graphic text needs to be put
  1473. to the screen using Text, like so:
  1474.  
  1475.         Rem * Simple Font Prog 1 *
  1476.         Get Fonts
  1477.         Paper 8
  1478.         Set Font 8
  1479.         Ink 2 : Text 5,50, `Amiga Computing`
  1480.  
  1481. The Get Fonts command scans the ROM and Fonts: directory on disk for fonts, and
  1482.  
  1483. Set Font sets  the font to be printed to the appropriate font in the pecking
  1484. order.
  1485.  
  1486. The colour of graphic fonts is set using the Ink command rather than Pen
  1487. (they`re drawn rather than printed, being graphics!). Once you have graphic
  1488. text under control you can do all manner of technical tricks like putting
  1489. shadows under the text
  1490.  
  1491.         Rem Totally Fontastic!
  1492.         Rem
  1493.         Paper 8 : Curs Off : Hide : Cls
  1494.         Get Fonts
  1495.         For F=1 To 30
  1496.         If Font$(F)
  1497.         Clw
  1498.         Print Font$(F)
  1499.         Set Font F
  1500.         For Y=20 To 150 Step 20
  1501.         SHAD[10,Y, `Amiga Computing`,1]
  1502.         Next
  1503.         Wait Key
  1504.         End If
  1505.         Next
  1506.         Procedure SHAD[X,Y,A$,D]
  1507.         Gr Writing 0
  1508.         Ink 0
  1509.         For DX=-D To D
  1510.         Text X+DX, Y-D,A$ : Text X+DX, Y+D,A$
  1511.         Next
  1512.         For DY=-D+1 To D-1
  1513.         Text X-D, Y+DY,A$ : Text X+D,Y+DY,A$
  1514.         Next
  1515.         Ink 2 : Text X,Y,A$
  1516.         End Proc
  1517.  
  1518. using JAM1 mode via the GR WRITING command to ensure a good impression. Or if
  1519. you`re particularly clever you can even add a drop shadow using the same
  1520. program but simply changing the last two lines:
  1521.  
  1522.         Ink 2 : Text X-2,Y-2,A$
  1523.         End Proc
  1524.  
  1525. This offsets the final white printing of the characters up and to the left of
  1526. the black outline, creating a drop shadow. Experiment with the code and see how
  1527. many effects you can do. How about making the last print in the same Ink as the
  1528. Paper colours for an outline font`
  1529.  
  1530. More exotic effects can be obtained using Aaron Fothergill`s CText program, in
  1531. which graphic text is taken to its extreme. If you get this program (either
  1532. from Aaron's Amos Club or Déjà Vu Software) you can create a font in Deluxe
  1533. Paint and include it in your program just like the pros do.
  1534.  
  1535. The font is stored on an IFF picture file like the example screen on this page,
  1536. and then scanned into CText a letter at a time. Then you can print it to the
  1537. screen in the same way you would ordinary text, or even do a scrolly message
  1538. across another screen.
  1539.  
  1540. Finally, Rainbow text is easy, and very effective. Basically what you have is a
  1541. rainbow you set up using the copper, and the text is like a lot of holes
  1542. punched through a screen covering the rainbow, giving you rainbow coloured
  1543. text! Try this listing to give you a taster:
  1544.  
  1545.         Rem * RainbowText.Amos *
  1546.         Rem
  1547.         Cls 0 : Curs Off : Hide
  1548.         Gosub STRIPES
  1549.         For X=0 To 23
  1550.         Pen 1 : Paper 0 : Print `Rainbow Text!!!
  1551.         Rainbow Text!!!`
  1552.         Next X
  1553.         Wait Key
  1554.         `
  1555.         STRIPES:
  1556.         Set Rainbow 0,1,280,??,??,??
  1557.         Rainbow 0,0,0,280
  1558.         Colour Back 0
  1559.         Restore RDATA
  1560.         For C=0 To 279 : Read CVA : Rain(0,C)=CVA
  1561.         Next C : View
  1562.         Return
  1563.         RDATA:
  1564.         Data $0,$0,$0,$111,$222,$333,$444,$555
  1565.         Data $666,$777,$888,$999,$AAA,$BBB,$CCC,$DDD
  1566.         Data $EEE,$FFF,$FFF,$EEE,$DDD,$CCC,$BBB,$AAA
  1567.         Data $999,$888,$777,$666,$555,$444,$333,$222
  1568.         Data $300,$200,$300,$400,$500,$600,$700,$800
  1569.         Data $900, $A00,$B00,$C00,$D00,$E00,$F00,$F00
  1570.         Data $E00,$D00,$C00,$B00,$A00,$900,$800,$700
  1571.         Data $600,$500,$400,$300,$200,$20,$30,$40
  1572.         Data $50,$60,$70,$80,$90,$A0,$B0,$C0
  1573.         Data $D0,$E0,$F0,$F0,$E0,$D0,$C0,$B0
  1574.         Data $A0,$90,$80,$70,$60,$50,$40,$30
  1575.         Data $30,$0,$1,$2,$3,$4,$5,$6
  1576.         Data $7,$8,$9,$A,$B,$C,$D,$E
  1577.         Data $F,$F,$E,$D,$C,$B,$A,$9
  1578.         Data $8,$7,$6,$5,$4,$3,$2,$1
  1579.         Data $0,$0,$22,$33,$44,$55,$66,$77
  1580.         Data $88,$99,$AA,$BB,$CC,$DD,$EE,$FF
  1581.         Data $FF,$EE,$DD,$CC,$BB,$AA,$99,$88
  1582.         Data $77,$66,$55,$44,$33,$22,£110,$220
  1583.         Data $330,$440,$550,$660,$770,$880,$990,$AA0
  1584.         Data $BB0,$CC0,$DD0,$EE0,$FF0,$FF0,$EE0,$DD0
  1585.         Data $CC0,$BB0,$AA0,$990,$880,$770,$660,$550
  1586.         Data $440,$330,$220,$101,$202,$303,$404,$505
  1587.         Data $606,$707,$808,$909,$A0A,$B0B,$C0C,$D0D
  1588.         Data $E0E,$F0F,$F0F,$E0E,$D0D,$C0C,$B0B,$A0A
  1589.         Data $909,$808,$707,$606,$505,$404,$303,$202
  1590.         Data $111,$222,$333,$444,$555,$666,$777,$888
  1591.         Data $999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF,$FFF
  1592.         Data $EEE,$DDD,$CCC,$BBB,$AAA,$999,$888,$777
  1593.         Data $666,$555,$444,$333,$222,$300,$200,$300
  1594.         Data $400,$500,$600,$700,$800,$900,$A00,$B00
  1595.         Data $C00,$D00,$E00,$F00,$F00,$E00,$D00,$C00
  1596.         Data $B00,$A00,$900,$800,$700,$600,$500,$400
  1597.         Data $300,$200,$20,$30,$40,$50,$60,$70
  1598.         Data $80,$90,$A0,$B0,$C0,$D0,$E0,$F0
  1599.         Data $F0,$0,$0,$0,$0,$0,$0,$0
  1600.  
  1601. Phew! Sorry about all that data, but it`s needed to give you the rainbow
  1602. stripes. And there you see it, rainbow text. Now let them try and ignore that
  1603. screen!
  1604.  
  1605.  
  1606. Issue 53 ­ October 1992
  1607. ` Using Amos to improve your computer's sound
  1608.  
  1609. One of the key things which distinguishes Amos from other types of Basic is its
  1610. grip on the Amiga`s breathtaking sound playing capability. But then again the
  1611. whole idea of Amos is the be able to access all the functions of the Amiga
  1612. rapidly and easily, using one command where previously only a few hundred would
  1613. do.
  1614.  
  1615. The Amiga can grab and play sampled sounds very easily. The sound chip can be
  1616. used, and samples can be put into a bank for you to use in your own programs.
  1617. Amos can also play music, like the ABK files on your demo disks. But for now
  1618. let`s talk about samples. Using sampled sounds is easy, and similar to the use
  1619. of IFF picture files, in as much as you can load them in off disk as they are
  1620. or use them from a bank.
  1621.  
  1622. You need an Amos program called Sam Maker, and this allows you to load samples
  1623. and put them together into a bank in memory. The problem with loading samples
  1624. from disk is that you have to BLOAD them and specify locations in memory and
  1625. all that, which is a little bit technical and not to say a touch heavy on
  1626. memory and resources.
  1627.  
  1628. It`s a far more elegant solution to store them in a bank as they are ready to
  1629. access at any time during your program, and they are loaded instantly. Once you
  1630. have your samples in a bank you can play them back at any speed, which changes
  1631. the time the sample takes to play and thus the pitch of the sample.
  1632.  
  1633. So you can either have samples of speech, snatches of music, or even single
  1634. notes of an instrument which you can play in a sound/noise/Pro Tracker-type
  1635. program at different pitches. Playing samples in Amos is a matter of using the
  1636. Sam Play command:
  1637.  
  1638.         Sam Play VOICE,SAMPLE,FREQUENCY
  1639.  
  1640. The voices your sample will use are set by setting a bit in V, like so:
  1641.  
  1642.         %1000 voice 3
  1643.         %1010 voice 3 and 2
  1644.         %1111 voices 3, 2, 1 and 0
  1645.  
  1646. This is all very well documented, but here`s an idea for you. The Amiga has
  1647. four voices, and these are paired to play in either left or right stereo
  1648. channel. Voices 0 and 3 play through the left speaker and 1 and 2 play through
  1649. the right.
  1650.  
  1651. It struck me the other day that it would be easy to take advantage of this
  1652. stereo capability and make stereo sounds - true stereo sounds, not just one
  1653. sound in one ear and another in the other ear like most programs you hear/see.
  1654.  
  1655. If you want to pan a sound around in the stereo spectrum you have to alter the
  1656. volume across the two stereo channels of the same sound. This is called mixing
  1657. or panning in the trade.
  1658.  
  1659. To clarify that, a sound appears in a certain position in the stereo `picture`,
  1660. an imaginary 3D space with a left, right, in and out, depending on how quiet or
  1661. loud it is in each ear. A noise which is soft in the left ear and loud in the
  1662. right will appear to come from right of centre in front of the listener.
  1663.  
  1664. So in order to simulate stereo panning in an Amiga sound, all you have to do is
  1665. put the same sound in both speakers and alter the volume of one or the other to
  1666. move the sound in space! Let`s try this out. Have your Amos Data disk in one of
  1667. your drives  and run the following program:
  1668.  
  1669.         Screen Open 0,640,256,16,Hires
  1670.         Hide : Curs Off : Paper 0 : Cls 0
  1671.         Load `Amos_Data:samples/samples.abk`
  1672.  
  1673. After all the usual setup, we load in some samples from the Amos Data disk. If
  1674. you don`t have this in the drive it`ll prompt you, because I`ve specified the
  1675. exact disk name in the Load statement:
  1676.  
  1677.         Sam Loop On
  1678.         Volume %10,0 : Volume %1,50
  1679.  
  1680. Then we turn Sam Loop On to make the sound continuous, and so make it easier to
  1681. hear the stereo panning. Next we set up the initial volumes of the two voices
  1682. we`ll be using, in this case voices 1 and 2, indicated by the binary codes
  1683. %0010 and %0001. This sets the volume so that the right channel is silent and
  1684. the left is set at 50:
  1685.  
  1686.         X=1
  1687.         Locate ,5 : Pen 4 : Centre `AC brings you *Stereo Panning*`
  1688.         Locate ,7 : Centre `The sound moves slowly from left to right`
  1689.  
  1690. Next we have the main program loop. The PANME procedure increments the right
  1691. and decrements the left at half second intervals until the sound has travelled
  1692. fully from left to right:
  1693.  
  1694.         Do
  1695.         Sam Play %11,3
  1696.         PANME
  1697.         Loop
  1698.         `
  1699.         Procedure PANME
  1700.         P1=0 : P2=50
  1701.         Repeat
  1702.         Volume %10,P1 : Volume %1,P2
  1703.         Wait 25
  1704.         Inc P1 : Dec P2
  1705.         Until P1=50
  1706.         End Proc
  1707.  
  1708. As they say in all the old Bond movies, crude but effective. If you were very
  1709. clever you could even have another sound panning the other way too.
  1710.  
  1711. Or even, and this is a really nice one, move the sound in stereo according to
  1712. movements from the joystick, which also moves the sprite that the sound relates
  1713. to! This would give you a real stereo effect for very little programming.
  1714.  
  1715. Simply put, this would involve the use of a simple test for the joystick
  1716. direction as another procedure at the end of the program, and putting the proc
  1717. name in the main loop. This routine gives you an idea of what I`m talking
  1718. about:
  1719.  
  1720.         Screen Open 0,640,256,16,Hires
  1721.         Hide : Curs Off : Paper 0 : Cls 0
  1722.         Load `Amos_Data:samples/samples.abk`
  1723.         Volume %10,25 : Volume %1,25
  1724.         P1=25 : P2=25
  1725.         Do
  1726.         Sam Play %11,3
  1727.         If Jleft(1) Then Inc P1 : Dec P2
  1728.         If Jright(1) Then Inc P2 : Dec P1
  1729.         If P1...
  1730.         If P2...
  1731.         Volume %10,P1 : Volume %1,P2
  1732.         Wait 25
  1733.         Locate 0,0 : Print P1,P2
  1734.         Loop
  1735.  
  1736. Once again it uses the samples from Amos_Data, but this time the sound pans in
  1737. stereo depending on whether you move the stick left or right. The location of
  1738. the sound is shown at the top of the screen.
  1739.  
  1740. Try that out at home this month, and try to make it faster still if you can.
  1741. Also, you can add a facility to pan the sound in and out as well as from left
  1742. to right, and move a sprite at the same time.
  1743.  
  1744.  
  1745. Issue 54 ­ November 1992
  1746. ` Manipulating and filling screens with all sorts of stuff
  1747.  
  1748. Although you may already know this, Amos has some very powerful commands for
  1749. the manipulation of screens and their contents. You will know by now how to
  1750. load and define screens, sure, even if you`ve only just bought the program.
  1751.  
  1752. What about moving screens around once you have them defined and loaded` Amos
  1753. has a number of very useful (I love understatement, don`t you?) commands for
  1754. manipulating screens, and these are easy to spot as they usually have the word
  1755. `screen` in them.
  1756.  
  1757. Screen Hide will take a screen you`ve loaded and send it away somewhere until
  1758. it is needed. To show it again you just need to use the Screen Show command.
  1759. Logical really, and as always in Amos Show and Hide are the exact opposite when
  1760. applied to what you might call visual commands.
  1761.  
  1762. The best place to hide an Amos screen of course is in a SPACKed memory bank and
  1763. a Packed Picture, as it takes up less memory. Screen Copy is used as a part of
  1764. the process of scrolling all or part of screens, in combination with Def
  1765. Scroll, Scroll and Screen Swap, as we see in this example:
  1766.  
  1767.         Load Iff `name your path and picture here`,1
  1768.         Screen Open 0,320,256,32,Lowres
  1769.         Get Palette 1 : Curs Off : Flash Off
  1770.  
  1771. This is all the usual setup guff, and if you`ve got any sense you`ll stick this
  1772. away as a file to merge to save you typing in all this before you begin. The
  1773. file you choose is loaded into screen 1, which at the moment is invisible:
  1774.  
  1775.         Screen Copy 1 To 0 : Screen 0 : Double Buffer : Bob Update
  1776. Off
  1777.  
  1778. You`ve opened a screen 0 and you`re copying screen 1 to 0, then making the
  1779. system show screen 0. Double buffering makes things nice and smooth by hiding
  1780. any loading of images:
  1781.  
  1782.         S=2
  1783.         Def Scroll 1,80,80 To 240,240,0,-S
  1784.  
  1785. S is the increment of the scroll, and the Def Scroll routine defines the area
  1786. of the scroll using the usual co-ordinates. Next you need to set up a loop and
  1787. feed the increments to it:
  1788.  
  1789.         Repeat
  1790.         For Y=0 To 199 Step S
  1791.         Scroll 1
  1792.         Screen Copy`` 1,80,Y,240,Y+S To 0,80,240-S
  1793.         Screen Swap
  1794.         Screen Copy 1,80,Y,240,Y+S To 0,80,240-S
  1795.         Wait Vbl
  1796.         Next Y
  1797.         Screen Swap : Wait Vbl : Scroll 1
  1798.         Until Mouse Key
  1799.  
  1800. So the area defined by the Def Scroll statement is scrolled upwards using the
  1801. Repeat Until loop. This is done over and over until any mouse button is
  1802. pressed, at which time the program stops. Choose a picture which has some
  1803. colours and shapes on it. If the picture is too plain you won`t really see the
  1804. effect.
  1805.  
  1806. Screen swap uses an `invisible` screen called the `logical screen` on which it
  1807. renders things like scrolls, like in our example. When the object or screen has
  1808. been modified, the results are copied to the real screen.
  1809.  
  1810. Logical screens are very useful for smoothing otherwise slow or clunky
  1811. rendering routines. Try the last example and alter the settings to see how it
  1812. changes when you adapt certain parts of the program, particularly the Def
  1813. Scroll and Screen Copy lines.
  1814.  
  1815. Now then, this is when it starts to get really interesting. In the Amiga`s
  1816. display system, a dual playfield is where two Amiga screens are visible at the
  1817. same time, overlaid one on the other, where one is visible through the other.
  1818.  
  1819. This is a handy effect for what they call in the game reviewing business
  1820. `parallax scrolling`, like in the game Shadow of the Beast. There is a good
  1821. Amos demo which parodies this effect, called Madness Week by the famous French
  1822. Amos hacker Syntex. Get it from the Amos PD Library, and you`ll see what I
  1823. mean.
  1824.  
  1825. ` Your letters
  1826. Paul Jermany writes: `Why is it that when I design a sprite using the Amos
  1827. Sprite Editor, for example a red apple, it appears blue on the screen, although
  1828. when I use the Bob command it appears as it should` I phoned the Amos help line
  1829. and they suggested the following:
  1830.  
  1831.         For 1=0 To 15
  1832.         C=Colour(1)
  1833.         Colour 16+1,C
  1834.         Next 1
  1835.  
  1836. At last I can get my sprites on the screen in their true colours, but the
  1837. program failed. Is it something I`m doing wrong`? You didn`t mention Paul if
  1838. you were using the Get Sprite Palette command. Are you` Of course you are. One
  1839. reason for the problem is that Bobs use the screen palette and the sprites use
  1840. the next 16 colours along, which is what your little proggy from Europress was
  1841. all about.
  1842.  
  1843. The thing is that the Amos Sprite Editor is in fact a Bob editor, which is why
  1844. if you load the objects as sprites you will get goofy colours. So use the Bob
  1845. commands and have done with it, that`s my advice to you. The speed difference
  1846. is minimal and the benefits of Bobs over sprites is worth it. Sprites are
  1847. hardware limited, and Bobs are no limits but slightly slower. I know which I
  1848. prefer.
  1849.  
  1850.  
  1851. Issue 55 ­ December 1992
  1852. ` Sprites and Bobs and how to move them around the screen
  1853.  
  1854. Almost every text written about Amos bangs on for quite some time about sprites
  1855. and Bobs, and now it`s my turn.. Of course, one of the things which makes Amos
  1856. so brilliant is its ability to slap objects on the screen and whizz them about
  1857. as fast as you like. Normal Basic just doesn`t cut it.
  1858.  
  1859. There are Bobs and there are sprites. Sprites are limited in size, and their
  1860. palette can only be the last 16 colours of a 32 colour display. So if the
  1861. sprite`s palette takes some of its colours from the first 16, those colours
  1862. will change with different backgrounds.
  1863.  
  1864. Great care is needed in the creation of sprites. Bobs make use of the blitter
  1865. chip in the Amiga, capable of copying images to the screen at rates close to a
  1866. million pixels per second. Bobs are just like sprites, but instead of being
  1867. limited in amount for size, they`re unlimited. They can have any colours and
  1868. resolutions, and you can use as you like on-screen.
  1869.  
  1870. Obviously the more Bobs you have on screen the more stress you put on memory
  1871. and processing time, but don`t worry about that. Bear in mind, though, that
  1872. Bobs are slower than sprites and use up more memory. As a rule of thumb, use
  1873. Bobs for slow moving and big shapes, and use sprites for fast moving small
  1874. shapes - that`s a fair division of labour. One other thing is that sprites can
  1875. be made to be bigger than the limit of 16 pixels, by using what they call in
  1876. Amos `computed sprites`.
  1877.  
  1878. The computer automatically sticks sprites together to make bigger sprites. You
  1879. can only have up to 128 pixels in width, as there are only eight hardware
  1880. sprites. The biggest mistake people make when using sprites or Bobs is to
  1881. instantly use AMAL when in fact they are going to compile the program anyway.
  1882.  
  1883. The sprite and Bob commands in Amos are so flexible you can ignore it except
  1884. for the most mundane tasks, and then once you`ve compiled the program, provided
  1885. your code is reasonably sensible and well ordered that is, the sprite will
  1886. whizz around like nobody`s business.
  1887.  
  1888. Once you`ve mastered the basics of sprite movement, which should take you about
  1889. ten minutes to suss, you face the prospect of all manner of objects whizzing
  1890. about missing each other and providing no information about their position or
  1891. any entertainment value whatsoever. Which is where this month`s program comes
  1892. in.
  1893.  
  1894. Obviously the sprites are from the excellent Sprite 600 set, available from
  1895. your Amos disks or via one of the various Amos PD outlets. In this example, the
  1896. spaceship meekly waits at the end of the screen, and you can`t move it at all.
  1897. The alien ship comes from the right of the screen, and when the ship is touched
  1898. by the alien it explodes beautifully. First, all the usual setup stuff:
  1899.  
  1900.         Screen Open 0,320,200,16,Lowres
  1901.         Curs Off : Flash Off : Hide : Cls 0
  1902.  
  1903. OK, so far so good. All the image information for the explosions etc are in the
  1904. sprite files, and like other examples which use the example sprite files, the
  1905. sprites are loaded one after the other into the same sprite bank.
  1906.  
  1907.         Load `df0:sprite_600/aliens/alien1.abk`
  1908.         Load `df0:sprite_600/space/ship3.abk`,1
  1909.  
  1910. If you wanted to make this program a little bit easier to handle - and cut out
  1911. the wait for the sprites to load from disk - you should load them in direct
  1912. mode and save them off with the program.
  1913.  
  1914. To be really kind you could load the sprite files into the bank, merging them
  1915. by adding the positive number to the end of the filename, and then save off the
  1916. bank to disk as a new ABK file.
  1917.  
  1918.         Get Sprite Palette
  1919.         Double Buffer
  1920.  
  1921. Once we have loaded the sprites we`ve set up DOUBLE BUFFER to prevent any
  1922. flickering of the sprites, and GET SPRITE PALETTE will make sure our sprites
  1923. are the same colours as they should be.
  1924.  
  1925. In this case, the sprites are from the same set so they are all the same
  1926. colours. If your sprites are of different palettes, you may have to re-edit
  1927. them and alter the palettes to fit.
  1928.  
  1929.         Bob 1,0,80
  1930.         Bob 2,320,80
  1931.         Shared M
  1932.         M=320
  1933.  
  1934. Next we set up the initial positions of the Bobs, and then define a variable as
  1935. shared for the position of the Bob in the proc called _ALIENMOVE. The reason
  1936. this variable is shared is that the proc is called each time the Bob is moved,
  1937. and so the variable has to be defined outside the Proc.
  1938.  
  1939. If the variable isn`t shared then it is always 0, as it never gets defined
  1940. according to the Proc. In this case this means that the sprite would suddenly
  1941. turn up in the same position as the ship and explode the ship right away,
  1942. rather than travelling gently across the screen. It`s an early bug in this
  1943. routine, which is how come I know about it! Next we loop.
  1944.  
  1945.         Do
  1946.         _SHIPANIM
  1947.         _ALIENMOVE
  1948.         If Bob Col(1) Then _YOURDEAD
  1949.         Loop
  1950.  
  1951. The main loop of the program is the DO LOOP, which will go on forever until the
  1952. Ctrl-C combo is pressed. The loop runs through the main parts of the program,
  1953. calling procs and then looping back to the start again.
  1954.  
  1955. Each time it calls the _ALIENMOVE proc the alien moves to the left. Each time
  1956. the _SHIPANIM proc is called the ship`s tail flame animates. This is an example
  1957. of animation without using AMAL. At the bottom of the proc we have the
  1958. collision detect routine which will trigger the Proc called _YOUREDEAD when the
  1959. alien makes contact with the ship. So add the procs:
  1960.  
  1961.         Procedure _ALIENMOVE
  1962.         M=M-5
  1963.         Bob 2,M,80,1
  1964.         End Proc
  1965.  
  1966.         Procedure _SHIPANIM
  1967.         For Y=18 To 21
  1968.         Bob 1,,,Y
  1969.         Wait Vbl
  1970.         Next Y
  1971.         End Proc
  1972.  
  1973.         Procedure _YOUREDEAD
  1974.         Boom
  1975.         For X=35 To 43
  1976.         Bob 1,0,80,X
  1977.         Wait 4
  1978.         Next X
  1979.         Pen 6 : Paper 0 : Centre `Kerboom! Yup, you`re dead!`
  1980.         Wait Key
  1981.         End
  1982.         End Proc
  1983.  
  1984. And that`s that. The _YOUREDEAD proc makes a boom noise and then animates the
  1985. explosion sequence from the sprite bank. This won`t work if the sprites are any
  1986. others than the ones specified, as they have specific images in the bank which
  1987. do certain jobs.
  1988.  
  1989. The sprite movement is a little jerky, even with double buffering. But you can
  1990. pep this up a little bit with careful program structure. As usual, with any
  1991. kind of coding planning is everything, and you have to carefully trace all your
  1992. procs and loops to make sure that nothing is happening out of turn and every
  1993. routine is working efficiently. Obviously all these problems vanish to a
  1994. certain extent when you compile a program.
  1995.  
  1996.  
  1997. Issue 56 ­ January 1993
  1998. ` Shedding some light on the subject of windows
  1999.  
  2000. The Amiga is a WIMP system, and by this I don't mean it backs away from a
  2001. fight. The idea of a computer interface containing windows, icons, mice and
  2002. pointers was originally developed by Xerox at Palo Alto Research Centre.
  2003.  
  2004. When the Amiga was designed in 1984/5, GUIs were all the range, so the
  2005. designers incorporated a mouse and a GUI called Workbench in the new machine.
  2006. Only with Amos can we get the real power of windows and menus. Although they're
  2007. not the kind of windows you're used to in Intuition, they are as functional.
  2008.  
  2009. If the type of programs you want to write err towards productivity or
  2010. utilities, then you'll have to use the windowing functions of Amos. A window is
  2011. basically an independent little area of text and graphics on the screen. To
  2012. open a window on the screen you must employ the WIND OPEN command , like so:
  2013.  
  2014.         Wind Open 1,10,10,50,10
  2015.  
  2016. This, for example would open a window on to the screen (window 1) which would
  2017. have its top left corner at screen location 10,10 and would be 50 characters
  2018. wide by 10 characters deep. The point of this is that you can have two or more
  2019. windows on the screen at the same time, all with their own text and graphics,
  2020. like this:
  2021.  
  2022.         Screen Open 0,640,200,16,Hires
  2023.         Cls 0
  2024.         Flash Off
  2025.         Paper 7: Wind Open 1,0,0,40,20 : Print "This is window number 1..."
  2026.         Paper 4 : Wind Open 2,320,0,40,20 : Print "...and this is number 2!"
  2027.         Wait Key
  2028.  
  2029. Each window acts like a little version of the screen and anything you can write
  2030. to a screen you can send to a window. Although the windows you get in Amos
  2031. aren't the same as the kind of thing you are used to in AmigaDOS, they still
  2032. have a range of styles and shapes, and can be made to act like "real" windows
  2033. with the minimum of tweaking.
  2034.  
  2035. For example, you can re-size them and even add gadgets like Intuition, but all
  2036. this must be done manually as Intuition is not loaded when Amos is running,
  2037. alas (all this is changing with Amos Professional, of course).
  2038.  
  2039. Re-sizing is a good example so let's look at that. Let's make a window on the
  2040. screen which you can pull at the bottom right-hand corner by clicking on it
  2041. with the left mouse button. The window can be resized on the screen, and when
  2042. you let go of the button the window snaps to that shape.
  2043.  
  2044. In order to grab anything on the screen ­ unlike the very convenient Intuition
  2045. code which does it all for you ­ you have to draw a window and then describe a
  2046. AZone around it to sense the presence of a mouse-click.
  2047.  
  2048. Then once you've sensed it you have to see where it moves, and then resize the
  2049. window with WIND SIZE. In this example, we first open a hi-res screen and set
  2050. the colours as normal:
  2051.  
  2052.         Screen Open 0,640,256,16,Hires
  2053.         Paper 0 : Cls 0
  2054.  
  2055. The we activate WIND SAVE, which mean our windows are smart and don't screw up
  2056. anything on the screen below them. This is really groovy because it means you
  2057. can open a window over a game screen for example,. like an IFF file. and
  2058. nothing on the screen will be erased when you close the window:
  2059.  
  2060.         Wind Save
  2061.  
  2062. Next we RESERVE ZONE, which is what you do every time you are about to SET
  2063. ZONE. What this means is that if you Reserve Zone 1 you are basically saying
  2064. "look, I'm going to define a zone later on in the program, so allocate some
  2065. memory for it and I'll get back to you":
  2066.  
  2067.         Reserve Zone 1
  2068.  
  2069. Now we set up all the characteristics of the window we'll be defining, in this
  2070. case Window 1 is a 20 x 20 character window, whose top left corner is
  2071. positioned at location 10,50 on the screen. After that we set the BORDER and
  2072. TITLE TOP functions to describe a little bit more about the window, like the
  2073. title text, in this case "Grab my corner, man!" and the colours of the border:
  2074.  
  2075.         Wind Open 1,10,50,20,20,1
  2076.         Border ,0,4
  2077.         Title Top " Grab my corner, man! "
  2078.         Set Zone 1,10,50, To 10+160,50+160
  2079.  
  2080. The last bit is the interesting part. Next we open up the zone we promised
  2081. earlier. It covers the area taken up by the window, and does this by specifying
  2082. the Zone number, in this case 1, and the co-ordinates of the top left and
  2083. bottom right corners of the Zone.
  2084.  
  2085. Bottom right is set here by lazily multiplying the top left figures by 160,
  2086. that is to say 8 x 20, 8 being the number of pixels in a character, and 20
  2087. being the width of the window. The we're into the main loop of the program:
  2088.  
  2089.         Do
  2090.                 If Mouse Key=1 and Mouse Zone=1
  2091.                         DX1=10 : DY1=50 : RESIZE ME
  2092.                         Reset Zone 1 : Set Zone 1,DX1,DY1 To DX2,DY2
  2093.                         ZX=(DX2-DX1)/8 : ZY=(DY2-DY1)/8
  2094.                         Wind Size ZX,ZY
  2095.                 End If
  2096.         Print "Amos Almanac. Better than a punch up in the throat...   ";
  2097.         Loop
  2098.  
  2099. This checks for the MOUSE KEY and MOUSE ZONE functions to see if the mouse is
  2100. within the zone and if it has the left mouse button pressed down. If it does
  2101. the PROC called RESIZE_ME is activated.
  2102.  
  2103. The PROC then does all the work, creating a rubber band effect to show you
  2104. where the sides of the window are, altering the variables containing the window
  2105. co-ordinates, and checking to see if the mouse button has been released yet
  2106. with the WHILE WEND
  2107. loop:
  2108.  
  2109.         Procedure RESIZE_ME
  2110.                 Shared DX1,DX2,DY1,DY2
  2111.                 Gr Writing 2
  2112.                 Repeat
  2113.                         If Mouse Key=1
  2114.                         DX2=X Screen(X Mouse) : DY2=Y Screen (Y Mouse)
  2115.                         0DX=DX2 : 0DY=DY2
  2116.                         While Mouse Key=1
  2117.                                 Box DX1,DY1 To DX2, DY2
  2118.                                 DX2=X Screen (X Mouse) : DY2=Y Screen (Y Mouse)
  2119.                                 Box DX1,DY1 To DX2,DY2
  2120.                         Wend
  2121.                         Box DX1,DY1 To 0DX,0DY
  2122.                         Box DX1,DY1 To DX2,DY2 : GOTIT=True
  2123.                         If DX1>DX2 : T=DX1 : DX1=DX2 : DX2=T : End If
  2124.                         If DY1>DY2 : T+DY1 : DY1=DY2 : DY2=T : End If
  2125.                         End If
  2126.                 Until GOTIT
  2127.                 Gr Writing 1
  2128.         End Proc
  2129.  
  2130. Once the button is released the window is redrawn to the new size. When the new
  2131. co-ordinates have been stored the old Zone is cancelled and re-drawn to the new
  2132. size, and it's all ready to start again.
  2133.  
  2134. And there you have it, perfect windows, and not a single patch of putty in
  2135. sight. Now you can create multiple-windowed programs and multi-windowed games
  2136. too! How about a Dungeon Master clone in the PD then?
  2137.  
  2138.  
  2139. Issue 57 ­ February 1993
  2140. ` How to put music to your creations
  2141.  
  2142. It seems that every program on the Amiga written with Amos has some lovely
  2143. piece of music to go with it. Don't you wish that you could make music like
  2144. that` Well you can.
  2145.  
  2146. It's tempting to steal other people's music off of bulletin boards, demos and
  2147. so on. But wait, don't touch that dial. The tracker programs you need to make
  2148. beautiful music are all public domain, with the exception of certain versions
  2149. of MED which are what they call "licenceware".
  2150.  
  2151. These disks costs a bit more than PD disks, but the author of the program gets
  2152. a royalty every time the program is sold. They almost always feature what we
  2153. call in the trade a "pattern editor" like you find on most modern drum machines
  2154. and certain Mini sequencers.
  2155.  
  2156. The sounds in trackers are always samples, like the kind you can make with your
  2157. own sound sampler, with the exception again of MED which also uses the sound
  2158. chip in the Amiga to create synthesized sounds, what we call "chip music". Most
  2159. trackers come with disks of sounds for you to get started. The way they work is
  2160. that you assemble patterns, short sequences of music lasting for 64 beats.
  2161.  
  2162. Then when you've made a pattern for your verse, chorus and other fill-ins etc,
  2163. you chain them all together to make a complete piece of music. You specify
  2164. which pattern you'd like to play and in what order, and the program plays each
  2165. pattern in turn to make meaningful music. Sometimes.
  2166.  
  2167. So for example you could have an intro on pattern 1, a verse on pattern 2, a
  2168. chorus on pattern 3 and a fill-in on pattern 4. The real kick of a pattern-
  2169. based sequencer is that you only have to input your patterns once and then they
  2170. can be played and arranged as many times as you like, rather than a more linear
  2171. system which would mean you'd have to type the tune in every time.
  2172.  
  2173. Creating pleasant music with a tracker is easy, as you can have four tracks (in
  2174. some cases even eight with programs like OctaMED Professional) and you can put
  2175. the notes in one at a time in what we call "step time", or play along with the
  2176. other tracks live on the keyboard in what is termed "real time".
  2177.  
  2178. Step time is easier for learners as you can fiddle about with each track of the
  2179. pattern until it sounds right, like typing words into a wordprocessor and
  2180. editing them until the spelling and syntax is perfect.
  2181.  
  2182. Once a piece of tracker music has been made, or produced, you can convert it to
  2183. Amos ABK format and load it into a program or into a bank in direct mode. The
  2184. Amos disks contain many different converters to serve most of the different
  2185. kinds of trackers such as Noisetracker, Soundtracker, StarTrekker, Protracker,
  2186. Games Music Creator, Sonix and so on.
  2187.  
  2188. All you do is run these very clever little Amos programs and they read in a
  2189. tracker file and spit out a ABK file onto disk ready to be loaded. Some of
  2190. these programs work fine, but the problem is that so many of the tracker
  2191. programs (being in the PD for some time now) have all been revamped and re-
  2192. written so that they are very different in format from the originals.
  2193.  
  2194. Some tracker tunes will not play properly once they've been converted. Usually
  2195. the reason is that the samples are too long or the system has changed. Either
  2196. the tracker has a pattern length which is variable and not fixed at 64, or it
  2197. stores its samples in a different way. Luckily, there are ways around this ­
  2198. see the programs documented in the box on this page for some ideas.
  2199.  
  2200. Do try to cultivate the use of tracker programs. You'll find they are not as
  2201. hard to use as you might think, and the results will be all your own work,
  2202. rather than just a steal from someone else.
  2203.  
  2204. A recent addition to the Déjà Vu licenceware library is Music Engine by Paul
  2205. Townsend (aka Technical Fred Software). This program lets you use tracker music
  2206. without having to convert it. What this program provides is an interface
  2207. between Amos and the Shell.
  2208.  
  2209. You can use this to play many different music file formats, and this is done by
  2210. running an appropriate "player program" which means you can hear the music
  2211. without having to convert it.
  2212.  
  2213. Once you've bought the Music Engine program from Déjà Vu, you are free to use
  2214. the source code, if it's for public domain,  shareware or licenceware use,
  2215. providing of course you acknowledge the source of your source.
  2216.  
  2217. If you want to use the routines in a piece of commercial software, however,
  2218. then you have to contact the programmers to arrange a suitable fee.  Music
  2219. Engine is a very powerful tool, and not just for driving music programs. The
  2220. trick is a very good one, and although it's handy for music, it's powerful
  2221. enough to run any program from the Workbench, effectively making your Amos
  2222. system multitask with other programs.
  2223.  
  2224. For more details of Music Engine (disk number LPD79) get in touch with Déjà Vu
  2225. Software, or write direct to: Technical Fred Software, 117 Hilton Lane,
  2226. Walkden, Worsley, Manchester M28 5TB. Phone or Fax: 061-703 7842.
  2227.  
  2228. Another fine program disk from the Amos PD Library is the MED Utils disk,
  2229. containing a copy of MED v2.13 and some convert utilities to make the
  2230. SoundTracker modules from MED more palatable to the ST-to-ABK converters. The
  2231. disk number is APD155
  2232.  
  2233. Lucky users of Amos Professional will know that, of course, Amos Pro is able to
  2234. use files from MED and Noisetracker (and it's various clones) directly using
  2235. libraries and features built into the program.  If you are using Amos Pro you
  2236. don't need to use a converter or any of the programs mentioned. You do however
  2237. need a copy of MED or Noisetracker to make the music in the first place.
  2238.  
  2239. I should also say that the most up to date version of MED isn't in the public
  2240. domain, but is available as licenceware, where the author gets a fee each time
  2241. the program is bought. You can get information about MED from Amiganuts United,
  2242. 12 Hinkler Road, Southampton SO4 6FT
  2243.  
  2244.  
  2245. Issue 58 ­ March 1993
  2246. ` Vectors ­ what they are and how to move them
  2247.  
  2248. Moving sprites on the screen is a pain in the bum, and no mistake. First you
  2249. have to get the damn things moving and then you've got to hold their hand every
  2250. step along the way, seeing what they hit, and then deciding how to bounce off
  2251. or explode depending on what the object you've hit is. It's like having kids,
  2252. or something.
  2253.  
  2254. Wouldn't it be so much nicer if you could just send an object off in a certain
  2255. direction and not worry about it until it actually does hit something? Well,
  2256. you can. But first a bit of maths (groan). No, don't turn the page. Maths is a
  2257. good thing. Keep that thought in mind and you'll last a lot longer as a
  2258. programmer!
  2259.  
  2260. Vectors are a method of moving objects around quickly and simply, with no
  2261. complex calculations or faffing about. They should be thought of as a change of
  2262. direction of an object (or point in space), rather than the usual way of moving
  2263. objects which is manually hiking them about using INC, DEC or things like
  2264. X=X+1.
  2265.  
  2266. It's the difference between picking a toy car up in the air and putting it
  2267. manually in another place (the old method) and pushing it along the ground and
  2268. letting go (like vectors). In Amos terms it works like this. As usual you use
  2269. the standard pair of variables to hold the X and Y co-ordinates of the sprite
  2270. or Bob position. So for example this is the vector demo program:
  2271.  
  2272.         Curs Off : Hide : Flash Off : Cls 0 : Ink 4,4 : Paper 0
  2273.         Input "What X ";DX#
  2274.         Input "What Y ";DY#
  2275.  
  2276. It's traditional to use the variables DX and DY, as these variables will tell
  2277. anyone reading your program that these are vectors. If your vectors are
  2278. designed to use an FPU (floating point unit), then append them with a hash or #
  2279. symbol.
  2280.  
  2281. In this demo program you start by inputting the x and y direction vectors ­
  2282. this has a result on the direction that the sprite will go. It's best to try a
  2283. range of numbers between -8 and 8 for each of the vectors. First the vectors
  2284. you require are accepted through the input command and stored in two variables
  2285. called DX and DY:
  2286.  
  2287.         Cls 0 : Bar 0,0 To 5,5
  2288.         Get Bob 1,0,0 To 6,6
  2289.         Cls 0
  2290.  
  2291. The Bob used in the program is grabbed from the screen using Get Bob, having
  2292. first been placed there using a Bar command. This is a good way of making
  2293. simple sprites without having to mess about with sprite editors or anything
  2294. silly like that. Next we want to talk about X and Y, which in this case are
  2295. floating point numbers so they are appended with #:
  2296.  
  2297.         X#=160 : Y#=100
  2298.  
  2299. Then the start position of the Bob is set to X=160 and Y=100, or slap dab in
  2300. the middle of the screen, as the screen we are looking at 320 by 200:
  2301.  
  2302.         While X#>0 and X#<320 and Y#>0 and Y#<200
  2303.            Bob 1,X#,Y#,1
  2304.            Wait Vbl
  2305.            X#=X#+DX#
  2306.            Y#=Y#+DY#
  2307.         Wend
  2308.         End
  2309.  
  2310. The While Wend loop moves the sprite in the direction given by the vectors.
  2311. After a while of running this program you'll be able to predict the precise
  2312. direction.
  2313.  
  2314. The Bob is moved until it reaches the edge of the screen, either less than
  2315. screen position 0 at the top or left of the screen, or screen position 320 or
  2316. 200 to the right or bottom.
  2317.  
  2318. Each time the While Wend goes around, the DX and DY vectors are added to the
  2319. current co-ordinates, affecting the direction of the sprite. The DY and DX
  2320. vectors can be positive or negative, and the speed of the movement can be
  2321. varied too.
  2322.  
  2323. You can put random speeds and random directions into a sprite making it
  2324. possible to simulate the bouncing of a ball in a ping pong or squash game, or
  2325. you can even simulate gravity, if you have the right formulae.
  2326.  
  2327. This is a very cool and efficient way of shifting objects around, and with a
  2328. little bit of experimentation you can create very realistic movements for your
  2329. sprites with very small code. A lot of Aaron Fothergill's ten-liners (Amos
  2330. games written in just ten lines of code!) use vectors to chop down the amount
  2331. of code needed to do very intelligent things. If you haven't seen any of these
  2332. disks, then join the Amos Club right away!
  2333.  
  2334. Why aren't you a member? If you're into Amos you might like to join the club.
  2335. Write for details to Amos Club, 1 Lower Moor, Whiddon Valley, Barnstaple EX32
  2336. 8NW.
  2337.  
  2338. You can even do vectors in 3D, but this is more complex (worth looking in to
  2339. though!). Obviously you have facilities at your disposal in Amos 3D to
  2340.  
  2341. translate objects in 3D, but a little bit of vector magic wouldn't hurt for
  2342. some really special effect.
  2343.  
  2344. The whole point is that vector riffs are small compared to those really big
  2345. routines which you can end up with when you try to do this stuff by hand.
  2346.  
  2347.  
  2348.                                     S O U R C E
  2349.  
  2350. This is a collection of Amiga Computing magazine's Amos columns, issues 42 to
  2351. 58, Nov 1991 to March 1993!
  2352.  
  2353.  
  2354.                                  I M P O R T A N T
  2355.                                  
  2356. This file taken from a PC, it seemed to confuse the "?" and "`" characters,
  2357. when I moved them to the Amiga, I have done my best to correct them, but you
  2358. may find the odd one that still needs swapping.  Sorry I couldn`t do them all,
  2359. but Amos is too hard for me, i`m still on 68000 myself!
  2360.  
  2361.  
  2362.  
  2363. CALL THESE BOARDS...
  2364.  
  2365.